oemof / DHNx

District heating system optimisation and simulation models
MIT License
27 stars 12 forks source link

To provide 'cbc' executable path. #86

Open fgunyel opened 2 years ago

fgunyel commented 2 years ago

settings = dict(solver='cbc', solve_kw={ 'tee': False, # print solver output }, solver_cmdline_options={

'allowableGap': 1e-5, # (absolute gap) default: 1e-10

                # 'ratioGap': 0.2,  # (0.2 = 20% gap) default: 0
                # 'seconds': 60 * 1,  # (maximum runtime) default: 1e+100
            },
            )

network.optimize_investment(invest_options=invest_opt, **settings)

gives an error:

ApplicationError: No executable found for solver 'cbc'

Altough cbc is installed. I want to be able to give its path. Is this possible?

joroeder commented 2 years ago

If you are using Windows, you might still need to add the installation path to your path variable. Please see the CBC installation instructions, or follow https://oemof-solph.readthedocs.io/en/latest/readme.html#installing-a-solver

fgunyel commented 2 years ago

Yes, that is exactly what I am looking for. The problem is that I am not able to specify the path for the "settings" since it does only take the solver name as input, but not where it is located. It must be something right:

settings = dict(solver='cbc', path=e.g. C:/Users/Somebody/my_program, .....)

The cbc is already succesfully installed in the PC.

joroeder commented 2 years ago

You need to add the solver to your PATH variable in Windows before. This has nothing to do with DHNx and the attributes of the optimisation method. Please see https://www.computerhope.com/issues/ch000549.htm

fgunyel commented 2 years ago

Thank you Johannes. I am working on Google Colab. I will try to find a way to define path variables there if I can. If I succeed, I put an update here.

fgunyel commented 2 years ago

!apt-get install -y -qq coinor-cbc import os !export cbc='/usr/bin/cbc' os.environ['cbc'] ='/usr/bin/cbc

The above code in Google Colab solves the problem, prior to calling cbc. Great!