Use cplex with c++: add conditional constraint

I'm new in cplex, I found in python the function: add_indicator_constraint, but in c++ I can't find anything like that. Can someone show me, please?

Upvotes: 0

Views: 137

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10059

in the example ilofixnet.cpp in CPLEX_Studio201\cplex\examples\src\cpp you can see a good example of indicator constraint in C++

// Add logical constraints that require x[i]==0 if f[i] is 0.
      for (IloInt i = 0; i < x.getSize(); ++i)
         model.add(IloIfThen(env, f[i] == 0, x[i] == 0));

Upvotes: 1

Related Questions