Overriding the Objective function

Hi Stefan,

I want to override the objective function, for example, minimizing the fuel consumption depending on the load in the vehicle. Do I simply need to override the SolutionCostCalculator interface, run the algorithm and the objective function will be minimized automatically. Or, I need to override also the ActivityInsertionCostsCalculator interface.

I also want to know when the SolutionCostCalculation gets to work in the search process, I mean (each activity insertion or iteration end or End of algorithm)

Thank you in advance for you help.

Hi @anasstaha19,

I am not Stefan and I am just trying to help out here as it has been 5 days.

Besides overriding the objective function, you also need a corresponding soft constraint which makes sure that the insertion heuristic is in line with the objective function. You can refer to the following texts on the algorithm walkthrough page of jsprit:

Note that if you set your own objective function, your insertion heuristic should insert the jobs according this function. Therefore you need to find appropriate soft constraints to penalyze bad and/or reward good insertion moves.

You can also refer to the examples Stefan provided in this stackoverflow post for how it is done.

Hopefully this answers your questions.

Best regards,

Thank you Jie for your respond.
I hope my understanding is correct. So the insertion is independent of the CostCalculator, like you said, if we want to override the objective function we need a soft constraint which makes sure the insertion is in line with this objective function. once we got a potential good insertion (solution), we calculate the final cost, which mean the objective function at the end of the iteration.

We can handle multi objective problems like this. I mean if we have a MIN & MAX objective functions, we need to create soft constraints that penalize bad and/or reward good insertion moves. Then at the end of each iteration we calculate the corresponding objective functions.

I know it’s more complicated than that, but I hope I am on the good way.