Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Facing problem in modeling

    Posted 01/15/12 09:35 AM

    Originally posted by: JDalal


    Hi,

    I am using CPLEX with C++ to model a facility location MIP problem. Suppose I := set of customer locations, J:= set of potential locations where facilities can open. Generally in textbook kind model, we use set I = set J and use IloNumVarArray to declare corresponding decision variables. For example, if I consider 50 locations, in x_ij both i and j indices are in {0,...49} or {1,...,50}

    The issue is: unlike standard formulations, suppose I have the customer set I ={10,15,21} and J={4,5,8}. Then how to declare all x_ij variables like x_{10,4}, ..., x_{21,8} using for loop?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Facing problem in modeling

    Posted 01/15/12 09:51 AM

    Originally posted by: JDalal


    I thought to better explain my question with a code snippet:

    My working code is:

    typedef IloArray<IloNumVarArray> IloNumVarArray2;
    .
    .
    .
    //declaring x_ij
    IloNumVarArray2 x(env, num_of_customers);
    for(int i=0;i<num_of_customers;i++){
    x[i] = IloNumVarArray(env, num_of_location, 0, 1, ILOFLOAT);
    }

    This is simple, since the indices i and j are just {0,...,num_of_customers} and {0,...,num_of_location}.
    Now I have the sets as some discrete integers like I={5,8,12} and j={2,21,49}.
    What is a n effective way of coding in this situation?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Facing problem in modeling

    Posted 01/15/12 12:00 PM

    Originally posted by: SystemAdmin


    In terms of your small example, why not just index customers 0..2 and locations 0..2? If the original indices (5, 8, 12 for customers; 2, 21, 49 for locations) have some significance elsewhere, you can store them in arrays (so that customer[0] = 5, location[0] = 2, etc.) for later use.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Facing problem in modeling

    Posted 01/15/12 06:36 PM

    Originally posted by: JDalal


    Thanks Paul.

    I thought about the same way. I was just wandering if there is any better way of doing it in Concert technology, so that I can get rid of mapping those indices with corresponding values in another array. Something that AMPL offers to its user - any number, or may be string can be used as index of a variable. However, it is possibly also using the same mapping technique internally and hiding the details from end user.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Facing problem in modeling

    Posted 01/17/12 11:11 AM

    Originally posted by: SystemAdmin


    I think it is not directly available in Concert. But it should be pretty easy to do that using either std::map<int,IloNumVar> or std::map<std::pair<int,int>,IloNumVar>.
    Using these types would allow you to index variables by any number or pair of numbers.
    #CPLEXOptimizers
    #DecisionOptimization