Decision Optimization

Decision Optimization

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

 View Only
  • 1.  I want change my type of var from Float to Int.

    Posted Sat April 03, 2010 06:49 AM

    Originally posted by: RaguNasu


    In a C++ application, I want change my type of var. How can I do.

    example:

    /*
    IloNumVarArray edge(env,38, 0, 1, ILOFLOAT);

    edge10(env, 0, 1, ILOBOOL);

    IloNumVarArray edge(env,38, 0, 1, ILOFLOAT); //RESET
    */
    This is a error example.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: I want change my type of var from Float to Int.

    Posted Sat April 03, 2010 12:53 PM

    Originally posted by: SystemAdmin


    In order to change the type of a variable you have to use class IloConversion. The reference manual has examples about how to change the type of a variable.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: I want change my type of var from Float to Int.

    Posted Sun April 04, 2010 12:17 AM

    Originally posted by: RaguNasu


    Thanks your answer.
    But I still have some problem.

    I can add Constraint frome ILOFLOAT to ILOINT.

    "model.add(IloConversion(env, edge [j], ILOINT));"

    But I can't add Constraint frome ILOINT to ILOFLOAT.

    "model.add(IloConversion(env, edge, ILOFLOAT)); //RESET"

    P.S.
    "IloNumVarArray edge(env, N*(N-1)/2, 0, 1, ILOFLOAT);"
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: I want change my type of var from Float to Int.

    Posted Tue April 06, 2010 03:03 AM

    Originally posted by: SystemAdmin


    What problems do you observe? Compiler, linker, runtime problems?

    Is it just a typo or did you leave out the index j in the second conversion intentionally?
    Your second conversion should read
    model.add(IloConversion(env, edge[j], ILOFLOAT)); // RESET
    

    Note the j index. There is no IloConversion constructor that accepts arrays as second argument.

    I guess you got an IloCplex::MultipleConversionException? Look at the reference manual.
    It explicitly states that there can be only one IloConversion for each variable.

    To remove a conversion from a model you should end() that conversion (this is also
    explained in the reference manual):
    // Add the conversion.
    IloConversion conversion(env, edge [j], ILOINT);
    model.add(conversion);
     
    // Remove the conversion.
    conversion.end();
    

    #CPLEXOptimizers
    #DecisionOptimization