0

I want to model an integer programming example with docplex in python. for an indicator constraint I have this equation (X is a binary variable):

equation

I wrote this code :

for i1,i2,i3 in P:
    mdl.add_indicator_constraints(x[(i,j,k)] for i,j,k in ijk if i==i1 and j==i2 and k==i3)==0

I don't know if I am using the right command for defining this indicator. when I run the program I get this error:

    cpx_indvars.append(logct.binary_var.safe_index)

AttributeError: 'Var' object has no attribute 'binary_var'

1 Answer 1

2

Your constraint does not look like and indicator constraint. An indicator constraint looks either like "if x=1 then ..." or "if x=0 then ..." where x is a binary variable. There seems to be no "then" part in your constraint.

In case you just want to fix the variable to 0 then you don't have to use an indicator constraint. Just add a regular constraint:

mld.add_linear_constraints(x[(i,j,k)] == 0 for i,j,k in ijk if i==i1 and j==i2 and k==i3)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.