Docplex package in python

Joined
Nov 8, 2022
Messages
1
Reaction score
0
Hi, I would like to write MILP model by using docplex in python. The model is below. I got this eror : "Cannot solve model: no CPLEX runtime found."
How can I solve it?

pip install docplex
from docplex.mp.model import Model
milp_model = Model(name = "MILP")

x = milp_model.binary_var(name = 'x')
y = milp_model.continuous_var(name = 'y', lb = 0)
z = milp_model.integer_var(name = "z", lb=0)
c1 = milp_model.add_constraint(x + 2*y + z <= 4, ctname = "c1")
c2 = milp_model.add_constraint(2*x + y <= 5, ctname = "c2")
c2 = milp_model.add_constraint(x + y >= 1, ctname = "c3")

obj_fn = 2*x+y+3*z
milp_model.set_objective('max', obj_fn)
milp_model.print_information()
milp_model.solve()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top