0
from docplex.mp.model import Model

m = Model(name="LP_Problem")
x1 = m.continuous_var(name="x1")
x2 = m.continuous_var(name="x2")
c11 = m.add_constraint( x1 + x2 <=  722)
c12 = m.add_constraint( 25 * x1 + x2 <= 685)
c13 = m.add_constraint( 48 * x1 + x2 <= 678.05)
c14 = m.add_constraint( x1 + x2 >= 705)
c15 = m.add_constraint( 25 * x1 + x2 >= 658.25)
c16 = m.add_constraint( 48 * x1 + x2 >= 650)
m.minimize(2085.05 - 74 * x1 - 3 * x2)
m.print_information()
s = m.solve()
m.print_solution()

OUTPUT

(venv) C:\Usears\goram\Code_files>python C:\Users\goram\Code_files\exp.py
Model: LP_Problem
 - number of variables: 2
   - binary=0, integer=0, continuous=2
 - number of constraints: 6
   - linear=6
 - parameters: defaults
 - objective: minimize
 - problem type is: LP
Traceback (most recent call last):
  File "C:\Users\goram\Code_files\exp.py", line 15, in <module>
    m.print_solution()
  File "C:\Users\goram\Code_files\venv\lib\site-packages\docplex\mp\model.py", line 6071, in print_solution
    self._check_has_solution()
  File "C:\Users\goram\Code_files\venv\lib\site-packages\docplex\mp\model.py", line 5189, in _check_has_solution
    self.fatal("Model<{0}> did not solve successfully", self.name)
  File "C:\Users\goram\Code_files\venv\lib\site-packages\docplex\mp\model.py", line 1080, in fatal        
    self._error_handler.fatal(msg, args)
  File "C:\Users\goram\Code_files\venv\lib\site-packages\docplex\mp\error_handler.py", line 210, in fatal 
    raise DOcplexException(resolved_message)
docplex.mp.utils.DOcplexException: Model<LP_Problem> 
did not solve successfully
Holt
  • 36,600
  • 7
  • 92
  • 139
Anil
  • 1
  • Cannot reproduce. Are you sure this is the exact code you're executing? Are you able to run the examples from docplex? What is the version of docplex you are using? Note that your model has no solution because `48 * x1 + x2 <= 678.05` implies that `x1 <= 671.05 / 48 ~ 14` and `x2 <= 678.05`, so `x1 + x2 <= 678.05 + 14 = 692` and you have `x1 + x2 >= 705`. – Holt Dec 07 '22 at 14:28
  • yes this is the exact code – Anil Dec 07 '22 at 17:22
  • solved the same LP Problem using a online solver and i am able to get a solution for the same – Anil Dec 07 '22 at 17:24
  • You did not solve the same LP. As I said, your LP is infeasible and it's trivial to prove (see my previous comment). – Holt Dec 07 '22 at 17:35

0 Answers0