Topic
  • 6 replies
  • Latest Post - ‏2016-10-27T14:37:56Z by CPlex_NooBie
Calvin Sun Hainan
Calvin Sun Hainan
23 Posts

Pinned topic Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

‏2013-09-26T10:55:25Z | opl script

I have an error message in my OPL script "Scripting runtime error: cannot convert to an integer, "2777734350"."

This is strange as OPL script should have no problem to handle a big integer value up to 9e+15 based on my previous understanding.

The only possible cause I can think about is the data type "var" not allow values as big as 2777734350.

In my script, I have some calculation like this.

int x = 2780000000;

execute {

             var a;

             ......

              x -= a;

}

It looks like OPL script tries to convert the variable "a" from "var" to "int" to do the calculation for "x". However, that fails for some reason.

  • AlexFleischer
    AlexFleischer
    2825 Posts
    ACCEPTED ANSWER

    Re: Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

    ‏2013-09-26T12:10:09Z  

    Hi,

     

    the integer values you can use in scripting are limited to pow(2,31)-1

     

    So for example

     

    int x=ftoi(pow(2,31)-1);
    int x2=x+1000;
     

    execute {
    x=x-1;   // works fine
    x2=x2-1; // does not work
             
               

    }

     

    regards

  • AlexFleischer
    AlexFleischer
    2825 Posts

    Re: Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

    ‏2013-09-26T12:10:09Z  

    Hi,

     

    the integer values you can use in scripting are limited to pow(2,31)-1

     

    So for example

     

    int x=ftoi(pow(2,31)-1);
    int x2=x+1000;
     

    execute {
    x=x-1;   // works fine
    x2=x2-1; // does not work
             
               

    }

     

    regards

  • Calvin Sun Hainan
    Calvin Sun Hainan
    23 Posts

    Re: Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

    ‏2013-09-27T01:08:55Z  

    Hi,

     

    the integer values you can use in scripting are limited to pow(2,31)-1

     

    So for example

     

    int x=ftoi(pow(2,31)-1);
    int x2=x+1000;
     

    execute {
    x=x-1;   // works fine
    x2=x2-1; // does not work
             
               

    }

     

    regards

    Thanks. I will change my variable type to float. That should fix the problem.

    Updated on 2013-09-27T01:13:29Z at 2013-09-27T01:13:29Z by Calvin Sun Hainan
  • Rajasekhar Kadambur
    Rajasekhar Kadambur
    30 Posts

    Re: Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

    ‏2014-02-12T12:26:34Z  

    I am using lamda values for solving multi-objective problem of order 43!(factorial) and the results is showing this error. will you explain this how to overcome this error.

     

    Warning:  Bound infeasibility column 'id32'.
    Warning:  Bound infeasibility column 'id32'.
    Warning:  -Infinity upper bound ignored.

  • CPlex_NooBie
    CPlex_NooBie
    16 Posts

    Re: Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

    ‏2016-10-27T11:00:37Z  

    Hi,

     

    the integer values you can use in scripting are limited to pow(2,31)-1

     

    So for example

     

    int x=ftoi(pow(2,31)-1);
    int x2=x+1000;
     

    execute {
    x=x-1;   // works fine
    x2=x2-1; // does not work
             
               

    }

     

    regards

    Hi Alex,

     

    What should I do if I have to use "ftoi" with the execute block?
    Is there any other function for it?

  • AlexFleischer
    AlexFleischer
    2825 Posts

    Re: Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

    ‏2016-10-27T11:06:41Z  

    Hi Alex,

     

    What should I do if I have to use "ftoi" with the execute block?
    Is there any other function for it?

    Hi,

    you may use "Opl." in execute blocks:

    float f=12000.0;
    int x=ftoi(f);

    int x2=0;
    execute
    {
    x2=Opl.ftoi(f);
    }
     
     assert x==x2;

    regards

  • CPlex_NooBie
    CPlex_NooBie
    16 Posts

    Re: Error message "Scripting runtime error: cannot convert to an integer, "2777734350"."

    ‏2016-10-27T14:37:56Z  

    Hi,

    you may use "Opl." in execute blocks:

    float f=12000.0;
    int x=ftoi(f);

    int x2=0;
    execute
    {
    x2=Opl.ftoi(f);
    }
     
     assert x==x2;

    regards

    Thanks, Alex!

    It worked!