Closed ThemisKoutsellis closed 1 year ago
I believe that you can already do pretty much everything you want with
pyomo solve --solver=glpk --logging=quiet --results=results.json osemosys.py *.dat
That writes the results as a json and not a pickle, but the json is probably more robust and likely faster in this case.
Unfortunately, the above solution seems to not working. I get the following:
ERROR: Unexpected exception while running model: Unknown results file format: results.json errorcode: 1 retval: None
At least is there a way around to suppress the cmd output? The printed python dict is extremelly large in some models, which causes computational resources issues.
Thank you in advance!
Themis
The --logging=quiet
option above is the option to turn off the output.
The --results=results.json
should be --results json
to switch the output format to use JSON instead of YAML (and should be slightly faster).
Thank you jsiirola for your reply!
The --results json
option, indeed, works now.
However, the--logging=quiet
option do not.
Because the results are not considered as logs.
Perhaps, pyomo considers as logs info such as whether the solution was feasible, the number of solutions etc, which indeed, when passing the--logging=quiet
argument, are not displayed. However, the large dict results on cmd are still there.
What version of Pyomo are you using? I cannot reproduce the behavior you describe with current release or development branch. I see:
~/ % pyomo solve --solver=glpk pmedian.py pmedian.test2.dat
[ 0.00] Setting up Pyomo environment
[ 0.00] Applying Pyomo preprocessing actions
[ 0.00] Creating model
[ 0.01] Applying solver
[ 0.02] Processing results
Number of solutions: 1
Solution Information
Gap: 0.0
Status: optimal
Function Value: 13.360120427317106
Solver results file: results.yml
[ 0.03] Applying Pyomo postprocessing actions
[ 0.03] Pyomo Finished
~/ %
and
~/ % pyomo solve --solver=glpk pmedian.py pmedian.test2.dat --results json --logging=quiet
~/ %
Without a complete example, there is little we can do to debug your problem.
I am using Pyomo==6.5.0 And the python pyomo model (OSeMOSYS model) and the corresponding dat file is here
the command I use is:
pyomo solve --solver=glpk --logging=quiet --results json osemosys.py UTOPIA_2015_08_27.dat
Here are the details of my execution:
I am using: ply==3.11 Pyomo==6.5.0 which is the latest pyomo version, I guess.
If a execute this cmd command:
pyomo solve --solver=glpk osemosys.py UTOPIA_2015_08_27.dat --results json --logging=quiet
I get the following on my terminal:
, which is an extremely large dictionary: The solution of model's variables (Too many variables in the model). *The cmd terminal only shows a portion of the printed dictionary
I cannot reproduce your observed behavior using either 6.5.0 or the main development branch (on Linux or Windows). I see no output to the console with the specified input files and command line. My guess is this is either an issue with running through Visual Studio or a problem with how you have things installed in the Visual Studio environment.
I tried different OS, different laptops, different set-ups. i.e., MAC. I also tried to execute the command from a cmd or MAC-terminal. Unfortunately, the same issue occurs! It seems, it is not an issue of VS-CODE but an issue of pyomo. I attach the full log files from my MAC. MAC-Terminal-log-file.txt Can we please open an issue for this behavior? Thank you in advance,
Themis
OK. This isn't a bug with Pyomo, but with the conda-forge/pyomo-feedstock recipe. Until the next release (due out in ~1 month), you can work around this by installing pyomo using pip
and not conda
.
Summary
I am using the "pyomo solve --solver=glpk osemosys.py *.dat" command. osemosys.py is a AbstractModel() instantiation. You can find the source code here
The results are always printed on the cmd. However, the outputs (it is a python dict) are extremely large yielding a slow OSeMOSYS-model solver execution.
Description