Hello,
I am currently modelling some optimal gas flow problems in Pyomo 5.6.1 (CPython 3.6.3 on Darwin 16.7.0) on macOS Sierra (10.12.6) and testing the performance of different models, including MILPs, MISOCPs and MINLPs. I would like to solve MINLP models with SCIP 6.0.1, but I am having trouble doing so. So far, I have tried two approaches
1) Directly calling SCIP from Pyomo using:
opt = SolverFactory('scip')
opt.solve(model, tee=True, keepfiles=False)
which returns an error (see scip_from_pyomo.png). From what I understand, Pyomo is trying to pass a .nl file to the SCIP executable, save the solution in a .sol file and recover it. For some reason, it seems like SCIP 6.0.1 cannot read the .nl file generated by Pyomo. I also tested it in the interactive shell with a different .nl file generated from Pyomo and ended up with the error shown in scip_reader.png.
2) Generating a .mps file from Pyomo, reading and solving it with SCIP from command line or in the interactive shell, writing a .sol file and loading the solution back into a Pyomo model instance, following the instructions given in a
previous post and the
Pyomo gallery. I slightly updated the code proposed there to incorporate it into my own, and ended up with this function to read the .sol file
def read_sol(self, sol_filename, symbol_map_filename, suffixes=[".*"]):
if suffixes is None:
suffixes = []
# parse the SOL file
with ReaderFactory(ResultsFormat.sol) as reader:
results = reader(sol_filename, suffixes=suffixes)
if results.solver.termination_condition != TerminationCondition.optimal:
raise RuntimeError("Solver did not terminate with status = optimal")
# regenerate the symbol_map for this model
with open(symbol_map_filename, "rb") as f:
symbol_cuid_pairs = pickle.load(f)
symbol_map = SymbolMap()
symbol_map.addSymbols((cuid.find_component(self.model), symbol)
for symbol, cuid in symbol_cuid_pairs)
# tag the results object with the symbol_map
results._smap = symbol_map
self.model.solutions.load_from(results)
When using it, I get the error shown in scipsol_to_pyomo.png. I also checked what happened when I tried to load .sol files generated by Gurobi 8.0.0 and CPLEX 12.8.0.0 for MISOCPs. The exact same procedure (write mps with Pyomo, then read, solve and write .sol file with Gurobi and CPLEX interactive shells) is followed, and errors are returned in both cases (see gurobisol_to_pyomo.png and cplexsol_to_pyomo.png). All .sol files used are attached to this post.
I am slightly stuck here, and before attempting anything else, I was wondering whether anyone was aware of an easy fix or work-around? Any help or ideas would be much appreciated.
Thank you in advance for considering this post,
Best,
Mathias Berger