Reputation: 131
I am currently using cplex with pyomo from the command line using
pyomo -solver=cplex model.py data.dat
the results are saved in the file results.json
.
How can I start cplex again using the previous results as a starting solution?
Upvotes: 3
Views: 1470
Reputation: 1436
If you want to do more advanced things like loading a warmstart it is better to start using Pyomo by writing your own Python scripts. In your case, this might look like:
from pyomo.environ import *
# import the module that contains your model
import model
# load the data
instance = model.model.create_instance('data.dat')
# create a solver
cplex = SolverFactory("cplex")
# solve the first time (tee=True prints the cplex output)
status = cplex.solve(instance, tee=True)
assert str(status.solver.termination_condition) == 'optimal'
# solve the model a second time and create a warmstart file for cplex
status = cplex.solve(instance, warmstart=True, tee=True)
See the scripting section of the online Pyomo docs for more on this.
Upvotes: 4