Decision Optimization

Decision Optimization

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

 View Only
  • 1.  A question about getRay()

    Posted Sun December 05, 2010 04:01 PM

    Originally posted by: QiuFeng


    Dear All:
    I have a question about getRay in concert. The manual says:

    quote
    public void getRay(IloNumArray vals, IloNumVarArray vars) const

    CPLEX puts the the variables of the extracted model into the array vars and it puts the corresponding values of the unbounded direction into the array vals.

    CPLEX resizes these arrays for you.
    [/quote]
    The above explanation in the manual seems to mean that the argument "vars" will be filled up with all variables. However, in many other functions, like getValues, "vars" is always passed to the function to tell CPLEX which variables are requested for values.

    So in order to match the values with the variables, extra work might have to be done, because the variables in the array "vars" might be in a different order from the variable array we are managing.

    My question here is that, do I have to do extra work to track variables ? like giving every variable a name.

    thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: A question about getRay()

    Posted Mon December 06, 2010 03:51 AM

    Originally posted by: SystemAdmin


    Does this thread help? It discusses some aspects of IloCplex::getRay() that seem to be similar to your issues.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: A question about getRay()

    Posted Mon December 06, 2010 11:32 AM

    Originally posted by: QiuFeng


    Thanks for pointing to this link, it explained the function's behavior in details.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: A question about getRay()

    Posted Mon December 06, 2010 11:00 AM

    Originally posted by: SystemAdmin


    > QiuFeng wrote:
    >
    > My question here is that, do I have to do extra work to track variables ?

    That depends on what you want to do with the ray components ('vals'). If you want to store them in a vector in the order that the original variables occurred (filling in zeros for components corresponding to variables that did not appear in 'vars'), then yes, you will have to do extra work. You don't necessarily need to assign names, though; you could just create a map whose keys are variables (instances of IloNumVar) and whose values are integers indicating the position of that variable in the sort sequence. Then you can assign vals[i] to the position the map gives you for vars[i].

    /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: A question about getRay()

    Posted Mon December 06, 2010 11:35 AM

    Originally posted by: QiuFeng


    Hi Paul, thanks for your reply. Now I'm using names to track variable. You mean I could use IloNumVar as key in map? Interesting, Is using IloNumVar as index very efficient? CPLEX did something to support comparison of two IloNumVar objects?
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: A question about getRay()

    Posted Mon December 06, 2010 12:27 PM

    Originally posted by: SystemAdmin


    What is safe and fast is using the pointer returned by IloNumVar::getImpl() as key. Or use the integer returned by IloNumVar::getId(). Both (pointer and id) are unique and should work fast in maps.
    There are various overloads of operator<, operator<= etc. on Concert that may apply to two IloNumVar instances but they all generate constraints rather than performing comparisons.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: A question about getRay()

    Posted Wed December 15, 2010 05:44 PM

    Originally posted by: QiuFeng


    Thanks! never thought about using id.

    In callable library, I use index to track variables. Is this a good way?
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: A question about getRay()

    Posted Thu December 16, 2010 09:48 AM

    Originally posted by: SystemAdmin


    Using the index of a variable is actually the best possible way :-) That is because in the callable library a variable is just a column index ...
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: A question about getRay()

    Posted Fri December 17, 2010 04:34 PM

    Originally posted by: QiuFeng


    Thank you, Daniel
    #CPLEXOptimizers
    #DecisionOptimization