Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  why the solution time is negative?

    Posted 09/29/08 08:00 AM

    Originally posted by: SystemAdmin


    [shaon said:]

    Hi, all

    I remotely call CPLEX 11.1 in my C program to solve MIP. I use the cut
    callback, incumbent callback, and branching callback.  Now I want to get the
    solution time.

    I use the general commands in other C language as follows:


    startTime= clock();

    ....................(main body)

    endTime = clock();

    solution_time = (double)(endTime - startTime)/CLOCKS_PER_SEC;


    When I solve small instance, I can get right computational time.

    But when I solve larger instance, for example no optimal solution can be
    found within 1 hours, the value of endTime will become a negative number
    during the iterations.

    when I check the value of endTime during the iteration, it becomes negative
    after the program works for about 2000 seconds.

    The value of  endTime = clock() should be positive.

    I do not know why the phenomenon comes up. Would you please give me a help?

    Thanks.

    Shaon

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: why the solution time is negative?

    Posted 09/29/08 06:57 PM

    Originally posted by: SystemAdmin


    [Sylvain said:]

    What is the exact type of endTime ?
    The type of the value returned by clock() is clock_t.
    So you should be sure that no type conversion is performed from the result of clock() to endTime as it could result in overflows or other approximations.

    Remember that the type int has a maximum value and if you add 1 to it, you will obtain the minimum value which is negative...

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: why the solution time is negative?

    Posted 09/29/08 07:20 PM

    Originally posted by: SystemAdmin


    [shaon said:]

    [quote author=Sylvain link=topic=590.msg1794#msg1794 date=1222696600]
    What is the exact type of endTime ?
    The type of the value returned by clock() is clock_t.
    So you should be sure that no type conversion is performed from the result of clock() to endTime as it could result in overflows or other approximations.

    Remember that the type int has a maximum value and if you add 1 to it, you will obtain the minimum value which is negative...




    I think there is no type error.

    First I define startTime and endTime as follows

    clock_t startTime, endTime; 

    So I think the definition is right.


    Shaon.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: why the solution time is negative?

    Posted 09/30/08 05:33 PM

    Originally posted by: SystemAdmin


    [Sylvain said:]

    I may have a hint for you but not the solution.
    Which platform are you using ? Is it Solaris by any chance ?

    Here is what I found a sun's forum after a quick google search :
    http://forums.sun.com/thread.jspa?threadID=5072081&tstart=345,

    According to the C standard (which is inherited by the C++ standard), function clock() returns a value of type clock_t, a typedef that is defined by the implementation. Different systems can have different definitions. The resolution of the value returned by clock is defined by the macro CLOCKS_PER_SECOND, which also can vary across systems.

    From the Solaris man page for clock():
    The value returned by clock() is defined in microseconds for compatibility with systems that have CPU clocks with much higher resolution. Because of this, the value returned will wrap around after accumulating only 2147 seconds of CPU time (about 36 minutes).

    For AIX, check the system documentation.

    Maybe your best option is to use an IloTimer, provided by Ilog tools.
    #CPLEXOptimizers
    #DecisionOptimization