IBM ILOG Dispatcher User's Manual > Transportation Industry Solutions > Adding Early and Late Costs > Suggested Answers > Exercise 4

How would the solving and goals code change if there were no early costs?

Suggested Answer

If there were no early costs, there would be no need to instantiate time, as the earliest possible delivery time would be the best delivery time. The modified code follows.

void RoutingSolver::solve() {
  IloDispatcher dispatcher(_solver);
  IloEnv env = _solver.getEnv();
  // Subgoals
  IloGoal subGoal = IloDichotomize(env,
                                   dispatcher.getCostVar(),
                                   IloFalse);
  IloGoal restoreSolution = IloRestoreSolution(env, _solution) && subGoal;
  IloGoal goal = IloSavingsGenerate(env) && subGoal;

  // Solving
  if (findFirstSolution(goal)) {
    improve(subGoal);
    _solver.solve(restoreSolution);
  }
}