Decision Optimization

 View Only
  • 1.  IloIntVar

    Posted Sat April 09, 2011 05:21 PM

    Originally posted by: banun


    Hi,

    I'm trying to create a variable for each node in a 3-d graph. - Node(x,y,z).
    each one of {x,y,z} can change.
    Is the IloIntVar(IloIntVar::ImplClass *) constructor suitable here ? I did not find any examples that use it...
    If not - what shoud I use ?
    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: IloIntVar

    Posted Sun April 10, 2011 04:15 PM

    Originally posted by: SystemAdmin


    C++ API? You could use built in array Concert array types. I would go with
    IloArray<IloArray<IloIntVarArray> > Node = ...
    

    Note the space between the two closing angle brackets, a syntactic necessity since C++ is the devil's tool.

    The warehouse.cpp example that comes with CPLEX shows how to build a two-dimensional array of IloNumVar. A three-dimensional array should be an easy extrapolation.

    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


  • 3.  Re: IloIntVar

    Posted Sun April 10, 2011 06:20 PM

    Originally posted by: banun


    hi and thanks for your answer,

    it's not so clear to me..
    How, for example, I refer to the y cord of Node, using your solution ?

    thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: IloIntVar

    Posted Mon April 11, 2011 08:30 AM

    Originally posted by: SystemAdmin


    I'm not sure what you mean by 'cord'. If you mean a slice along the y dimension (i.e., all nodes where y=y0, any x, any z), you would have to use a loop:

    for (int x = 0; x < xmax; x++) {
      for (int z = 0; z < zmax; z++) {
        // do something with Node[x][y][z]
      }
    }
    


    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


  • 5.  Re: IloIntVar

    Posted Sun April 10, 2011 06:20 PM

    Originally posted by: banun


    hi and thanks for your answer,

    it's not so clear to me..
    How, for example, I refer to the y cord of Node, using your solution ?

    thanks
    #CPLEXOptimizers
    #DecisionOptimization