Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
2.01k stars 518 forks source link

pyomo not working with cbc solver #2699

Closed grgmiller closed 1 year ago

grgmiller commented 1 year ago

Summary

When attempting to solve a model using the CBC solver, I am getting an error about the -printingOptions option being invalid. I'm not sure if this option was removed in the newest version of CBC and if I need to try using an older version of CBC for this to work?

Error Message

ERROR: Solver (cbc) returned non-zero return code (4294967295)
ERROR: Solver log: Error: invalid option '-printingOptions'
Traceback (most recent call last):
  File "A:\miniconda3\envs\match_model\Scripts\match-script.py", line 33, in <module>
    sys.exit(load_entry_point('match-model', 'console_scripts', 'match')())
  File "a:\github\match-model\match_model\main.py", line 38, in main
    main()
  File "a:\github\match-model\match_model\solve_scenarios.py", line 169, in main
    solve.main(args=args)
  File "a:\github\match-model\match_model\solve.py", line 171, in main
    results = solve(instance)
  File "a:\github\match-model\match_model\solve.py", line 902, in solve
    results = model.solver_manager.solve(model, opt=model.solver, **solver_args)
  File "A:\miniconda3\envs\match_model\lib\site-packages\pyomo\opt\parallel\async_solver.py", line 28, in solve
    return self.execute(*args, **kwds)
  File "A:\miniconda3\envs\match_model\lib\site-packages\pyomo\opt\parallel\manager.py", line 118, in execute
    ah = self.queue(*args, **kwds)
  File "A:\miniconda3\envs\match_model\lib\site-packages\pyomo\opt\parallel\manager.py", line 133, in queue
    return self._perform_queue(ah, *args, **kwds)
  File "A:\miniconda3\envs\match_model\lib\site-packages\pyomo\opt\parallel\local.py", line 52, in _perform_queue
    results = opt.solve(*args, **kwds)
  File "A:\miniconda3\envs\match_model\lib\site-packages\pyomo\opt\base\solvers.py", line 595, in solve
    raise ApplicationError(
pyomo.common.errors.ApplicationError: Solver (cbc) did not exit normally

Information on your system

Pyomo version: 6.4.0 Python version: 3.10.8 Operating system: Windows 10 How Pyomo was installed (PyPI, conda, source): conda Solver (if applicable): cbc v20221228

Additional information

blnicho commented 1 year ago

@grgmiller could you provide a minimal example that reproduces the error? I'm curious how you're specifying the solver option.

grgmiller commented 1 year ago

I will try and create an example, but for a bit more context, I am using the MATCH model, which uses pyomo. The model reads solver options from a text file, if specified. In this case, however, I am not specifying any solver options, so there should not be any options passed to the solver by the MATCH model.

This is the solve function in MATCH: https://github.com/pencleanenergy/MATCH-model/blob/4c4122a91601e126280fec7db93d8e7d5dde6a03/match_model/solve.py#L837

jsiirola commented 1 year ago

Pyomo adds -printingOptions all in both pyomo/solvers/plugins/solvers/CBCplugin.py and pyomo/contrib/appsi/solvers/cbc.py. My question is where are you getting CBC from? "20221228" does not match the (historical?) CBC versioning scheme: the most recent [as of a couple months ago] release was 2.10.4 if you built all of coin-binary, or 2.10.8 if you worked things to just build cbc.

grgmiller commented 1 year ago

I am downloading the cbc standalone executable from https://ampl.com/products/solvers/open-source-solvers/, which is where the cbc github page points to https://github.com/coin-or/Cbc

jsiirola commented 1 year ago

Got it. That is not a general build of CBC: that is CBC compiled against the ASL (i.e., it is CBC for AMPL). You should be able to use that through Pyomo's "nl" interface using the solver name asl:cbc.

grgmiller commented 1 year ago

Ah thank you @jsiirola that seems to have fixed the issue.