Phillip,
I think the easiest way to do this would be to clone your model before sending it to a solver. For example:
model2 = model.clone()
SolverFactory(‘ipopt’).solve(model)
In this case ‘model’ will have the solution loaded and ‘model2’ will not.
Bethany
--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Philipp, you should be able to use something like the following. I created two functions – one to store the values of all the variables into a component map, and one to retrieve all the values from the component map (and put them back into the variables). Let me know if you have any questions, or this does not work.
def get_var_value_map(model):
var_value_map = pe.ComponentMap()
for v in model.component_data_objects(ctype=pe.Var, descend_into=True):
var_value_map[v] = pe.value(v)
return var_value_map
def set_var_value_from_map(model, var_value_map):
for v in var_value_map:
v.set_value(var_value_map[v])
# store the current values in a component map
var_value_map = get_var_value_map(model)
# solve the problem
results = pe.SolverFactory('ipopt').solve(model)
# do something with solution
# ...
# restore the previously stored values
set_var_value_from_map(model, var_value_map)