I am relatively new to Pyomo and was trying to find a way to do the following: I have a robot model which consists of many variables, parameters, constraints and an objective function. The model consists of torques and contact penalties. After running the ipopt solver (specifying initial and final conditions along with initializing the variables) the solution was optimal. The objective function only incorporated contact penalties.
I would like to rerun the model with the above solution as initialized values but with an updated the objective function (which includes both contact penalties and torque^2). Is there a way to do this?
The reason for not including it in the first run is that the solver tends to take super long and either return infeasible or has a restoration error. Doing it this way allows me to find a feasible solution and thereafter the optimal one.
I have tried the following example here. However, I'm unsure on how to incorporate the updated objective function.
There are a few options for changing the objective function between solves. The first is to declare multiple
Objectivecomponents and useactivateanddeactivateto swap which one gets sent to the solver:Another way is to use mutable
Paramcomponents to change weights in the objective function:Finally, you could use
Expressioncomponents for different terms in the objective function which could be modified independently between solves: