optimizationamplcontent-delivery-network

Using conditional statements for CPLEX resolver


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?


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).