Question

Is it possible to use in AMPL conditional statements such as "if (...) then..."? Below is shown as I tried to do.

subject to c1a {k in K, o in O, n in N: n!=t[k,o]}:
sum{e in E}
   (a[n,e]*x[e,k,o]) -
sum{e in E}
   (b[n,e]*x[e,k,o]) =
            (if (r[n,k]==1 and f[n,o]==1) 
                then d[k,o]*(1-f[k,o])
                else 0);

My ampl returning to me bug as follows:

CPLEX 11.2.0: Constraint _scon[1] is not convex quadratic since it is an equality constraint.

Do you have any idea ho to resolve this problem?

Was it helpful?

Solution

It is possible to use if-then-else expression with CPLEX if the condition (the expression between if and then) doesn't contain variables. CPLEX also supports so called "indicator constraints" (see here for more details) which use implication operator (==>) and are somewhat similar to if-then-else, but allow variables in the condition.

Regarding your example, it is not clear which names correspond to variables and which to constraints but the error suggests that the problem is not due to if-then-else, but because you have a quadratic constraint in the form not supported by CPLEX (see the section Quadratic Constraints on page 33 of ILOG AMPL CPLEX System User's Guide for the information about the accepted form).

OTHER TIPS

you may change your solver cplex only deal with convex and quadratic constraints and it's used byt default in Ampl resolution, so you can try to repload your mod and dat files and then choose another solver as follow:

ampl: option solver " ipopt";
ampl: solve;

or

ampl: option solver " couenne";
ampl: solve;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top