0

How can I store the text version of a constraint defined as a docplex.mp.linear.LinearExpr variable into a Python string variable?

Omar Shehab
  • 1,004
  • 3
  • 14
  • 26

1 Answers1

1

Use its string representation as returned by str(ct).

nbbus50 = mdl.integer_var(name='nbBus50')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')

ct1 = nbbus50 * 50 + nbbus40 * 40 + nbbus30 * 30 >= 200
print(f"str(ct1)= {str(ct1)}")

str(ct1)= 50nbBus50+40nbBus40+30nbBus30 >= 200

Philippe Couronne
  • 826
  • 1
  • 5
  • 6