Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Using the multiplication of a float and an integer parameter for defining a range

    Posted 03/24/16 12:21 PM

    Originally posted by: story_


    Hello all,

    I have to define the upper bound of a range that takes value based on an integer parameter. Let's assume that this parameter is called R and equals to 10. So I want this range to have an upper bound of R/2 or 10/2=5. When I try to assign this value of 5 to an integer variable in order to define the upper bound of the range, I get the error "Cannot use type float for int" as 0.5 is not an integer value, however the value I am trying to get is still an integer one.


    How may I make sure that I end up with an integer variable for the upper bound (maybe via a function for rounding float parameters)? What are your suggestions to solve this issue?

    Thanks in advance,


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Using the multiplication of a float and an integer parameter for defining a range

    Posted 03/24/16 12:32 PM

    Could you provide a code example? I am not sure computed bounds are allowed in the place in which you are trying to use them.

    Have you tried using ftoi() to explicitly convert the float to an int?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Using the multiplication of a float and an integer parameter for defining a range

    Posted 03/24/16 12:41 PM

    Originally posted by: story_


    Yes, certainly. Here's my code:

     int R[1..T] = ...; //Integer parameters that I want to define the lower and upper bound of a range with
     int upr1=2*R[1]; //Upper bound of the range
     int lw1=R[1]/2; //Lower bound of the range - the error occurs here
     range rr1=lw1..upr1;

    I haven't tried using ftoi() for the conversion.

    Edit: Using ftoi() seems to work perfectly fine. Thanks!


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Using the multiplication of a float and an integer parameter for defining a range

    Posted 03/25/16 01:30 PM

    Well, then how about just trying ftoi() :-)

    The following seems to work for me (does not give an error):

    int lw1=ftoi(round(R[1]/2));

     


    #CPLEXOptimizers
    #DecisionOptimization