Implementing the Check to Finish the Iteration Loop

  1. Reading input arguments for the increment value and the number of iteration
  2. Registering the variables to increment
  3. Registering the targets to have in the report
  4. Implementing the incrementation of the variables
  5. Implementing the reception of the new measures
  6. Implementing the check to finish the iteration loop
  7. 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
}