Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Add constraints into IloRangeArray

  • 1.  Add constraints into IloRangeArray

    Posted Mon March 16, 2015 10:13 PM

    Originally posted by: wzyryan


    Hello all,

                 I want to add the two IloIfThen constraints into an IloRangeArray con. Does anyone have any idea how to implement it? Thanks a lot! The values of w and h are both 128. t[0] and t[1] are decision variables.

    for(int p=0;p<w;p++){
       for(int q=0;q<h;q++){
          
           model.add(IloIfThen(env, mat[p][q] >= t[0], fmat[p][q] >= t[0]));
               model.add(IloIfThen(env, mat[p][q] <= t[1], fmat[p][q] <= t[1]));
     
    
       }
    }
    

    What I want to implement is as follows:

    IloRangeArray con(env);
    for(int p=0;p<w;p++){
        for(int q=0;q<h;q++){
            con.add(IloIfThen(env, mat[p][q] >= t[0], fmat[p][q] >= t[0]));
            con.add(IloIfThen(env, mat[p][q] <= t[1], fmat[p][q] <= t[1]));
        }     //The expression above is obviously wrong. How can I implement it?
    }
    

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Add constraints into IloRangeArray

    Posted Tue March 17, 2015 03:28 AM

    Since IloIfThen is not a subclass of IloRange this is not possible (this is general object oriented programming, not anything related to CPLEX).

    You may want to use an IloConstraintArray instead of an IloRangeArray since IloConstraint is a common base class of IloRange and IloIfThen (see also the reference documentation).


    #CPLEXOptimizers
    #DecisionOptimization