bjodah / chempy

⚗ A package useful for chemistry written in Python
BSD 2-Clause "Simplified" License
544 stars 78 forks source link

running an example in README.rst triggers a warning and a diagnostic dump #170

Closed matecsaj closed 4 years ago

matecsaj commented 4 years ago

from chempy import balance_stoichiometry from pprint import pprint pprint([dict(_) for _ in balance_stoichiometry({'C', 'O2'}, {'CO2', 'CO'}, underdetermined=None)])

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pulp/pulp.py:1190: UserWarning: Spaces are not permitted in the name. Converted to '' warnings.warn("Spaces are not permitted in the name. Converted to ''") Welcome to the CBC MILP Solver Version: 2.9.0 Build Date: Feb 12 2015

command line - /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pulp/apis/../solverdir/cbc/osx/64/cbc /var/folders/jy/txq0svb52s5drzcmw93j87m00000gn/T/a513b22ee4b14893a06dbdbd9d0b79f3-pulp.mps branch printingOptions all solution /var/folders/jy/txq0svb52s5drzcmw93j87m00000gn/T/a513b22ee4b14893a06dbdbd9d0b79f3-pulp.sol (default strategy 1) At line 2 NAME MODEL At line 3 ROWS At line 7 COLUMNS At line 26 RHS At line 29 BOUNDS At line 34 ENDATA Problem MODEL has 2 rows, 4 columns and 6 elements Coin0008I MODEL read with 0 errors Continuous objective value is 5.5 - 0.00 seconds Cgl0003I 0 fixed, 3 tightened bounds, 0 strengthened rows, 0 substitutions Cgl0004I processed model has 1 rows, 3 columns (3 integer (0 of which binary)) and 3 elements Cutoff increment increased from 1e-05 to 0.9999 Cbc0012I Integer solution of 8 found by DiveCoefficient after 0 iterations and 0 nodes (0.00 seconds) Cbc0031I 1 added rows had average density of 1 Cbc0013I At root node, 1 cuts changed objective from 7 to 8 in 3 passes Cbc0014I Cut generator 0 (Probing) - 0 row cuts average 0.0 elements, 1 column cuts (1 active) in 0.000 seconds - new frequency is 1 Cbc0014I Cut generator 1 (Gomory) - 1 row cuts average 1.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is 1 Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0001I Search completed - best objective 8, took 0 iterations and 0 nodes (0.00 seconds) Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost Cuts at root node changed objective from 7 to 8 Probing was tried 3 times and created 1 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) Gomory was tried 3 times and created 1 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) Knapsack was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) Clique was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) MixedIntegerRounding2 was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) FlowCover was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) TwoMirCuts was tried 1 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)

Result - Optimal solution found

Objective value: 8.00000000 Enumerated nodes: 0 Total iterations: 0 Time (CPU seconds): 0.00 Time (Wallclock seconds): 0.00

Option for printingOptions changed from normal to all Total time (CPU seconds): 0.00 (Wallclock seconds): 0.01

[{'C': 3, 'O2': 2}, {'CO': 2, 'CO2': 1}]

bjodah commented 4 years ago

@matecsaj Thank you for reporting this. I don't get as mouch output as you do, is it macOS specific? But I think I fixed the warning.

matecsaj commented 4 years ago

@bjodah if you give me a heads up when the new version is available via pip update then I'd be happy to test the fix on my Mac. I don't have another coding environment.

bjodah commented 4 years ago

@matecsaj great, I've just uploaded v0.7.12

matecsaj commented 4 years ago

You made progress, there is no longer a warning about spaces.

Welcome to the CBC MILP Solver Version: 2.9.0 Build Date: Feb 12 2015

command line - /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pulp/apis/../solverdir/cbc/osx/64/cbc /var/folders/jy/txq0svb52s5drzcmw93j87m00000gn/T/1e9a3b48c3ea42ef832fe4540edb9c8e-pulp.mps branch printingOptions all solution /var/folders/jy/txq0svb52s5drzcmw93j87m00000gn/T/1e9a3b48c3ea42ef832fe4540edb9c8e-pulp.sol (default strategy 1) At line 2 NAME MODEL At line 3 ROWS At line 7 COLUMNS At line 26 RHS At line 29 BOUNDS At line 34 ENDATA Problem MODEL has 2 rows, 4 columns and 6 elements Coin0008I MODEL read with 0 errors Continuous objective value is 5.5 - 0.00 seconds Cgl0003I 0 fixed, 3 tightened bounds, 0 strengthened rows, 0 substitutions Cgl0004I processed model has 1 rows, 3 columns (3 integer (0 of which binary)) and 3 elements Cutoff increment increased from 1e-05 to 0.9999 Cbc0012I Integer solution of 8 found by DiveCoefficient after 0 iterations and 0 nodes (0.00 seconds) Cbc0031I 1 added rows had average density of 1 Cbc0013I At root node, 1 cuts changed objective from 7 to 8 in 3 passes Cbc0014I Cut generator 0 (Probing) - 0 row cuts average 0.0 elements, 1 column cuts (1 active) in 0.000 seconds - new frequency is 1 Cbc0014I Cut generator 1 (Gomory) - 1 row cuts average 1.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is 1 Cbc0014I Cut generator 2 (Knapsack) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0014I Cut generator 3 (Clique) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0014I Cut generator 4 (MixedIntegerRounding2) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0014I Cut generator 5 (FlowCover) - 0 row cuts average 0.0 elements, 0 column cuts (0 active) in 0.000 seconds - new frequency is -100 Cbc0001I Search completed - best objective 8, took 0 iterations and 0 nodes (0.00 seconds) Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost Cuts at root node changed objective from 7 to 8 Probing was tried 3 times and created 1 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) Gomory was tried 3 times and created 1 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) Knapsack was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) Clique was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) MixedIntegerRounding2 was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) FlowCover was tried 3 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds) TwoMirCuts was tried 1 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)

Result - Optimal solution found

Objective value: 8.00000000 Enumerated nodes: 0 Total iterations: 0 Time (CPU seconds): 0.00 Time (Wallclock seconds): 0.00

Option for printingOptions changed from normal to all Total time (CPU seconds): 0.00 (Wallclock seconds): 0.00

[{'C': 3, 'O2': 2}, {'CO': 2, 'CO2': 1}]

Process finished with exit code 0

matecsaj commented 4 years ago

Omitting a parameter makes it run clean.

from chempy import balance_stoichiometry
from pprint import pprint

#pprint([dict(_) for _ in balance_stoichiometry({'C', 'O2'}, {'CO2', 'CO'}, underdetermined=None)])
pprint([dict(_) for _ in balance_stoichiometry({'C', 'O2'}, {'CO2', 'CO'})])

[{'C': x1 + 1, 'O2': x1 + 1/2}, {'CO': 1, 'CO2': x1}]

Process finished with exit code 0

matecsaj commented 4 years ago

The following line in the dump caught my eye, perhaps it is a clue.

Option for printingOptions changed from normal to all

matecsaj commented 3 years ago

This issue persisted for me, and after becoming more accustomed to chempy, I contributed a PR to remedy. See https://github.com/bjodah/chempy/pull/183.