IBMDecisionOptimization / docplex-examples

These samples demonstrate how to use the DOcplex library to model and solve optimization problems.
https://ibmdecisionoptimization.github.io/
Apache License 2.0
396 stars 228 forks source link

DOcplexException: CPLEX runtime not found: please install CPLEX or solve this model on DOcplexcloud #23

Closed vgexl closed 4 years ago

vgexl commented 4 years ago

Hi,

I recently install Jupyter for Cognos Analytics which embed Jupyter in Cognos.

I got this error after trying code below. Could you help ?

thank you


DOcplexException Traceback (most recent call last)

in () 8 mdl.minimize(nbbus40*460 + nbbus30*360) 9 ---> 10 sol=mdl.solve() 11 12 for v in mdl.iter_integer_vars(): ~/.local/lib/python3.7/site-packages/docplex/mp/model.py in solve(self, **kwargs) 4208 else: 4209 # no way to solve.. really -> 4210 return self.fatal("CPLEX runtime not found: please install CPLEX or solve this model on DOcplexcloud") 4211 finally: 4212 try: ~/.local/lib/python3.7/site-packages/docplex/mp/model.py in fatal(self, msg, *args) 887 888 def fatal(self, msg, *args): --> 889 self._error_handler.fatal(msg, args) 890 891 def fatal_ce_limits(self, *args): ~/.local/lib/python3.7/site-packages/docplex/mp/error_handler.py in fatal(self, msg, args) 208 resolved_message = resolve_pattern(msg, args) 209 docplex_error_stop_here() --> 210 raise DOcplexException(resolved_message) 211 212 def fatal_limits_exceeded(self): DOcplexException: CPLEX runtime not found: please install CPLEX or solve this model on DOcplexcloud I try to run these commands : !pip install --user docplex !pip install --user cplex ``` import cplex from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.integer_var(name='nbBus40') nbbus30 = mdl.integer_var(name='nbBus30') mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids') mdl.minimize(nbbus40*460 + nbbus30*360) sol=mdl.solve() for v in mdl.iter_integer_vars(): print(v," = ",v.solution_value) ```
vgexl commented 4 years ago

Hi For an unknown reason it's now ok. Sorry for the inconvenience. Here my code

!pip install --user docplex
!pip install --user cplex
!python -c "import cplex; print(cplex.__version__)"
import cplex
print(cplex.__version__)
import sys
import cplex
from docplex.mp.model import Model

mdl = Model(name='buses')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')
mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids')
mdl.minimize(nbbus40*460 + nbbus30*360)

sol=mdl.solve()

for v in mdl.iter_integer_vars():
    print(v," = ",v.solution_value) 

get : nbBus40 = 6.0 nbBus30 = 2.0