Decision Optimization

Decision Optimization

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

 View Only
  • 1.  creating vars

    Posted Sat April 30, 2011 05:19 PM

    Originally posted by: banun


    Hi,
    I wrote the following function that creates a variable :
    {
    IloInt one,two;
    one = val-radius;
    two = val+radius;
    IloIntVar var(env, one, two, ILOINT, name);

    var.setName(name.c_str());

    return var.getId()
    }

    radius and val are int,
    name is string
    the compiler complains :

    no matching function for call to ‘IloIntVar::IloIntVar(IloEnv&, IloInt&, IloInt&, std::string&)’
    candidates are:...

    What's wrong with my function ?
    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: creating vars

    Posted Sat April 30, 2011 06:54 PM

    Originally posted by: RodrigoLinfati


    try:

    IloIntVar var(env, one, two, name);
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: creating vars

    Posted Sat April 30, 2011 06:57 PM

    Originally posted by: banun


    I tried that, still the same message from the compiler :

    no matching function for call to ‘IloIntVar::IloIntVar(IloEnv&, IloInt&, IloInt&, std::string&)’
    candidates are...
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: creating vars

    Posted Sat April 30, 2011 08:02 PM

    Originally posted by: RodrigoLinfati


    try:

    IloIntVar var(env, one, two, name*.c_str()*);
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: creating vars

    Posted Sun May 01, 2011 04:29 AM

    Originally posted by: banun


    I get :

    error: expected primary-expression before ‘.’ token
    error: expected primary-expression before ‘)’ token

    another question - one and two are actually like constraints here ?
    meaning, that variable I'm creating here is greater than one and smaller than two, and it's an integer. Is that correct ?

    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: creating vars

    Posted Sun May 01, 2011 07:28 AM

    Originally posted by: RodrigoLinfati


    IloIntVar var(env, one, two, name.c_str() );

    one is the lower bound of the variable, the minimal value
    two is the upper bound of the variable, tha maximal value
    name is a "C string", ie, an array of char.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: creating vars

    Posted Sun May 01, 2011 03:56 PM

    Originally posted by: banun


    thanks, it works now.

    regarding my second question :

    is IloIntVar var(env, one, two, name.c_str() ); equals to :

    creating var like that :
    IloBoolVar var(env);
    var.setName(name.c_str());

    and afterwards creating a constraint for it :

    someshing like:

    add(var >= one);
    add(var <= two);
    ?
    #CPLEXOptimizers
    #DecisionOptimization