0

I'm doing an optimization problem and after give the command:

results = solver.solve(model,tee=True)

I will have all my variables solved inside the model object.

There is a way to save and load this model object?

  • if you want solve the whole model, including the results, the you can cloudpicke it as shown [here](https://stackoverflow.com/a/51181213/8784382). Otherwise, you can just exctract the variable values and store them through a common python library to a file. – Giorgio Balestrieri Feb 19 '19 at 23:19

1 Answers1

1

The variables will be inside your "model" object, if you have a variable called "A":

model.A.value

will give you its value (or model.A[index].value if it is indexed)

  • If you just want to use the results later in your code just call the value when needed (as shown above)
  • If you want to save them for later The best is to have a function that exports the results towards dictionaries, panda dataframes, and then you can save to txt, csv or excel files using pickle or pandas for excel.
  • You can also save your entire model to a file using "cloudpickle" (it will however not work if you try to open it with a too different environment)