Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Memory Leak: Garbage Collection

    Posted Tue November 15, 2011 10:18 PM

    Originally posted by: SystemAdmin


    Hi all,

    I am having trouble when I run the models for several times within the same OPL main loop. Since I am using CP, I am posting to this forum, But this maybe related to general OPL. Here is my situation.

    I have two CP models: the first one is an assignment model, the second one is the scheduling. I need to run these two models 100 times for 100 different random realizations. Instead of having 100 different model and data files, I am using a main loop based on a main data file which is basically an Excel file.

    First of all, I have a windows 64 environment. I am using OPLRUN to execute my main model and the related data file. I am accessing the data in an Excel file.

    What happens in my code is like this. I generate the main model. Then create a copy of it. Then there is a loop (for 100 times) for the random realizations. Within this loop, I first solve the assignment problem and have a solution. Based on the solution I create a text data file for the secondary scheduling model. Then the secondary scheduling model is solved and the solution is processed. It seems I cannot use end() methods to clean the model and data objects at this point. What I suspect is that each time main and secondary models are generated, object manager keeps the earlier model and data objects. It never deletes them automatically. I am not able to use the end() methods otherwise OPLRUN crashes.

    If I turn on "thisOplModel.settings.mainEndEnabled = true;" option, it crashes as well. The way I am using the end() method is like this for example: "submodeldata.end();" "submodel.end();".

    Is there anything that I am missing? What should I do for the garbage collection?

    Thanks in advance,

    Ayhan Demiriz
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Memory Leak: Garbage Collection

    Posted Wed November 16, 2011 07:50 AM
    Hi,

    could you post your model?

    Regards
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Memory Leak: Garbage Collection

    Posted Wed November 16, 2011 09:22 AM

    Originally posted by: SystemAdmin


    Here is my main model. If needed I can post the sub model file as well.

    Ayhan
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Memory Leak: Garbage Collection

    Posted Wed November 16, 2011 11:53 AM
    Hi

    posting the models and the data could help.
    Besides using the latest version could help too.
    Are you using OPL 6.3?
    The latest version is CPLEX Optimization Studio 12.3.

    Regards
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Memory Leak: Garbage Collection

    Posted Wed November 16, 2011 03:59 PM

    Originally posted by: SystemAdmin


    Yes I am using OPL 6.3. I had some issues when I installed Cplex 12.3. For instance, I was NOT able to run my CP models in parallel mode. It never utilized the full CPU. I got suspicious about it. Then I saw a patch posted in one of the forums and downloaded it. The installer did not recognize that I had Cplex 12.3 installed. So I completely deleted and try again. It did not work either. I gave up the idea of using CPLEX 12.3. I think IBM has some issues about that product.

    I am an academic user and working on a paper. I am gonna make my model and data file public once I publish my paper. However I am not able to share my files further at this moment. Can you give me some pointers to look?

    Thanks,
    Ayhan
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: Memory Leak: Garbage Collection

    Posted Thu November 17, 2011 06:14 AM

    Originally posted by: rdumeur


    Dear ademiriz,

    We're contacting the appropriate team to get their advice on the memory problem.
    About the parallel mode problem, could you please describe your machine better? We need to know the number of available cores and available memory as well. Having an idea of the model sizes is also interesting (number of variables, constraints and so on).

    Cheers,
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: Memory Leak: Garbage Collection

    Posted Thu November 17, 2011 08:29 AM

    Originally posted by: SystemAdmin


    Thanks for your kind reply.

    The problem sizes are not the main issue here. The individual steps can be run perfectly on my laptop which is a quad core, 4 GB memory, Win 7 Enterprise 64Bit. I am running my experiments on a server which runs on Win 2008 Server 64 bit and has two quad-core Xeon processors with 14GB memory.

    I am following the examples from your code samples. I do not think I have a very poor written code. All I want is to be able to run the same two models for 100 times. But it never releases the memory from the earlier steps. It accumulates the memory. The end() method is not doing what it suppose to do. After a while (in some problems 60 steps), it hits the memory limit. Then oplrun crashes. Right now my experiments are run in "Quiet" mode so they do not generate any log. Let me run them separately. I'll post some stats on them.

    I tried to install Cplex 12.3 for only my laptop. Since I was not successful at all, I did not want to create problems for the server. Never tried it on the server.

    Thanks,
    Ayhan
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: Memory Leak: Garbage Collection

    Posted Thu November 17, 2011 08:38 AM

    Originally posted by: SystemAdmin


    I want to add one more thing to my earlier message. Even in the code samples you have, the way main block work is questionable. Maybe it is me who got it wrong but in order to do anything we need to generate the problem first with the associated data file. We cannot touch that object at that moment. It does not allow to update any data (model variable) before actually solving it. To make even a slight change, we need to copy the entire object which I have no clue why. After creating a copy of it I can then make updates to reoptimize the model. That part looks to me restrictive. Is there a better way to avoid it? Maybe I have not thought more on that? Maybe I got it wrong from the beginning?

    Thanks,
    Ayhan
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: Memory Leak: Garbage Collection

    Posted Thu November 17, 2011 08:58 AM

    Originally posted by: SystemAdmin


    Here is some stats about the assignment and scheduling problems. You'll see they are very simple models.

    !
    ! Minimization problem - 9 variables, 1 constraint
    ! Workers = 4
    ! TimeLimit = 300
    ! Initial process time : 0.00s (0.00s extraction + 0.00s propagation)
    ! . Log search space : 28.5 (before), 28.5 (after)
    ! . Memory usage : 626.7 Kb (before), 626.7 Kb (after)

    Solution status : Terminated normally, optimal found (tol. = 1.#INF)
    ! Number of branches : 742,556
    ! Number of fails : 368,859
    ! Total memory usage : 4.7 Mb (4.0 Mb CP Optimizer + 0.6 Mb Concert)
    ! Time spent in solve : 18.13s (18.13s engine + 0.00s extraction)
    ! Search speed (br. / s) : 40,963.4
    !
    ! Search terminated, replaying optimal solution

    Here is the result for the scheduling model which is my secondary model

    !
    ! Minimization problem - 4,935 variables, 5,845 constraints
    ! Workers = 4
    ! TimeLimit = 400
    ! Initial process time : 0.06s (0.00s extraction + 0.06s propagation)
    ! . Log search space : 60,546.7 (before), 60,546.7 (after)
    ! . Memory usage : 7.3 Mb (before), 15.0 Mb (after)
    Solution status : Terminated normally, optimal found (tol. = 1.#INF)
    ! Number of branches : 10,169
    ! Number of fails : 2,543
    ! Total memory usage : 243.2 Mb (225.9 Mb CP Optimizer + 17.2 Mb Concert)
    ! Time spent in solve : 87.86s (87.86s engine + 0.00s extraction)
    ! Search speed (br. / s) : 115.7
    !
    ! Search terminated, replaying optimal solution
    "Random Realization 1",117543,47285,62.67760998030204
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 10.  Re: Memory Leak: Garbage Collection

    Posted Thu November 17, 2011 11:16 AM

    Originally posted by: rdumeur


    Dear ademriz,

    Indeed the models are not very large. I understand you don't want to publish them but any simplified model exhibiting the problem would help us very much in determining the cause of the problem.

    Cheers,

    Renaud
    #DecisionOptimization
    #OPLusingCPOptimizer