offgridders icon indicating copy to clipboard operation
offgridders copied to clipboard

Issue with Offgridders Setup: Solver (cbc) Returned Non-Zero Return Code (1)

Open IlariaDelF opened this issue 1 year ago • 7 comments

Hello Offgridders Team, I'm currently setting up and running simulations with Offgridders, but I've encountered an issue related to the CBC solver. The solver returns a non-zero return code (1) with the error message:

ERROR: Solver (cbc) returned non-zero return code (1) ERROR: Solver log: Error: cbc 2.10.10: invalid option '-ratioGap'

The simulation initiates but fails when the CBC solver is called, with the error message mentioned above.

System Details: Operating System: Windows 10 Offgridders Version: I'm not able to see it from the Offgridders.py or setup.py Python Version: 3.6 (via Miniconda) (But I also tried with Python 3.7 and got the same error) Environment: Created using pip in a Conda virtual environment Installed Packages: ampl-module-base==20240606 ampl-module-cbc==20240529 amplpy==0.14.0 ampltools==0.7.5 appdirs==1.4.4 blinker==1.5 certifi==2021.5.30 charset-normalizer==2.0.12 cycler==0.11.0 decorator==4.4.2 dill==0.3.4 future @ file:///D:/bld/future_1610147365175/work idna==3.7 kiwisolver==1.3.1 matplotlib==3.0.0 networkx==2.5.1 nose==1.3.7 numpy==1.19.5 oemof.network==0.4.0rc0 oemof.solph==0.4.1 oemof.tools==0.4.0 Offgridders @ file:///C:/Users/Ilaria/offgridders pandas==0.23.4 ply==3.11 Pyomo==5.7 pyparsing==3.1.2 python-dateutil==2.9.0.post0 pytz==2024.1 PyUtilib==6.0.0 requests==2.27.1 scipy==1.4.1 six==1.16.0 urllib3==1.26.19 wincertstore==0.2 xlrd==1.2.0 XlsxWriter==1.2.7

I noticed that the issue arises from an invalid option -ratioGap being passed to the CBC solver. I'm not sure where this option is being set within the code.

I would appreciate any guidance on how to resolve this issue. Also, if there's any additional information you need, please let me know.

Thank you in advance for your help!

IlariaDelF avatar Jul 31 '24 10:07 IlariaDelF

Hi @IlariaDelF! Thank you for the error messages, now I know what your problem is. It is a dependency-Problem, but luckily only with the cbc solver. Meaning at one part of the code. Two ways to go about it:

  1. Try changing the Option to "AllowedGap" in the input excel sheet: grafik

  2. If that does not work, you need to go into the code itself, to this code section: https://github.com/rl-institut/offgridders/blob/9095014d054b26e1c0a02b51d237840e1b8e9ea6/src/G1_oemof_create_model.py#L538-L546

And remove following lines (I hope this will activate the default settings of the cbc solver): https://github.com/rl-institut/offgridders/blob/9095014d054b26e1c0a02b51d237840e1b8e9ea6/src/G1_oemof_create_model.py#L543-L545

smartie2076 avatar Jul 31 '24 12:07 smartie2076

Hi @smartie2076 ! Thank you for the help. I tried both but with the first the error remains the same and with the second I get this error now:

Error: cbc 2.10.10: invalid option '-printingOptions' ERROR: Solver (cbc) returned non-zero return code (1)

IlariaDelF avatar Jul 31 '24 13:07 IlariaDelF

  1. Option: @IlariaDelF, Are you sure you edited the excel file that you are calling with with terminal input/tool execution? If you change the excel sheet it should indeed change the inputs and therefore the error messages...

  2. Option: The new error message is surprising, as we did not hard-code the use of -printingOptions in Offgridders. It might be an oemof.solve or pyomo default? In that case, I am not sure where to fix it. Can you try an older cbc solver version, for example v2.10.5?

smartie2076 avatar Aug 01 '24 11:08 smartie2076

Hi, When I first tried, I changed the input files but it was giving this error: 13:51:37-ERROR-No cases defined to be simulated. Did you set any perform_simulation=True in excel template, tab CASE_DEFINITIONS?

Despite I did set to "True" one of the cases. So I thought to run the downloaded excels inputs as a "test" and here is where I find the cbc error of -ratioGap.

I then went back to my project's input excels and tried to set to True also a second case (even if I'm only interested in the pv-diesel-storage-mg case. Here I got back the same cbc error of -ratioGap.

IlariaDelF avatar Aug 02 '24 12:08 IlariaDelF

Hi @IlariaDelF ! I just did a clean reinstall with Offgridders, using the requirements.txt of the current release. I had to fix numpy==1.19.5 to avoid an error, and used pandas==0.25.3. With the cbc.exe I still have on my computer, the simulation runs through without a problem using the test data (python Offgridders.py ./inputs/test_input_template.xlsx).

Maybe the CBC version really is the problem here. Can you check your CBC version? I did so by double clicking on my cbc file in the file explorer. This opens a terminal with:

Welcome to the CBC MILP Solver
Version: 2.10.5
Build Date: Nov 24 2021

Or did you install cbc with this?

python -m pip install amplpy –upgrade
python -m amplpy.modules install cbc

I was able to recreate your issue regarding -ratioGap by downloading the cbc executable from https://ampl.com/products/solvers/open-source-solvers/#cbc (version “20240724”). I also have the problem of -printingOptions now. I tried for a couple of hours now but could not figure out how to fix this.

Maybe you can find the old cbc solver version that I use?

smartie2076 avatar Aug 02 '24 15:08 smartie2076

Hi @smartie2076! Thank you so much for the help! I managed to make it run with my site data :) I'll take some days to understand the results and might rise another issue later regarding the possibility of using directly the PV and battery size in the inputs sensitivity instead of their cost.

IlariaDelF avatar Aug 05 '24 15:08 IlariaDelF

Dear all,

I have been trying to run Offgridders with the following setup:

Windows 10 64bit Conda virtual environment with python 3.7 requirements_dev.txt

...and also encountered problems with the cbc solver most likely related to its version: pyutilib.common._exceptions.ApplicationError: Solver (cbc) did not exit normally

The oldest version of a directly usable cbc.exe I found was 2.10.6 available here: https://github.com/coin-or/Cbc/releases

There are other versions available here: https://www.coin-or.org/download/binary/Cbc/

It did not manage to find a working cbc solver, but an older version (2.10.3) I had on my computer works perfectly fine for the test_input_template.xlsx

Would it be possible to simply add a compatible cbc.exe to this repository? If not, are there other ways to ensure compatibility with newer versions of cbc, eg. those available from AMPL as instructed?

All the best!

MaaJoo13 avatar Jan 07 '25 22:01 MaaJoo13