Implementing the Check to Finish the Iteration Loop
- Reading input arguments for the increment value and the number of iteration
- Registering the variables to increment
- Registering the targets to have in the report
- Implementing the incrementation of the variables
- Implementing the reception of the new measures
- Implementing the check to finish the iteration loop
- Outputting a report file
The way it is currently setup, this will loop infinitely because the implementation of StartIteration
returns true all the time.
Therefore, you need to check at the beginning if you want to end or not the iterations.
/// <summary>
/// Callback called upon starting a new iteration in the optimization loop
/// </summary>
/// <param name="iteration">the iteration that is starting</param>
/// <returns> whether we should continue on this iteration or not</returns>
public bool StartIteration(int iteration)
{
// Start : code added to end the loop on the wanted iteration
if(iteration >= _iterationNumber)
{
return false;
}
// End : code added to end the loop on the wanted iteration
foreach(var key in _variableValues.Keys)
{
_variableValues[key] = _variableValues[key] + _incrementValue;
}
return true; // we want to continue looping on this iteration
}