Decision Optimization

 View Only
  • 1.  How to Find the memory (RAM) , CPU Usage when running docplex model

    Posted Wed December 02, 2020 10:38 PM
    1. Imagine I ran an optimization model written on docplex successfully. I need to know how I can find to run that model what are the resource usage for using cplex engine. I think we can find this by the cplex optimization studio - profiler section when running OPL models. I need to know how we an get this using python docplex.

    2. In Windows Task Manager enables  monitor the applications, processes, and services currently running  PC. When running cplex optimization studio what is reflected in this services area to show that cplex is running. 

    ------------------------------
    Suresh Abeyweera
    ------------------------------

    #DecisionOptimization


  • 2.  RE: How to Find the memory (RAM) , CPU Usage when running docplex model

    Posted Mon December 07, 2020 08:43 AM

    Unfortunately, there is no way to track the engine memory for CPLEX MIP/LP in Python. You can have a look at the tracemalloc Python module https://docs.python.org/3/library/tracemalloc.html. It can help to track CPLEX memory and peak memory usage.

    However, if you are using docplex CP (CP Optimizer)  then this feature is available. Here is an example of usage:

    res = mdl.solve()
    infos = res.get_solver_infos()
    infos.write()  # Display all information 
    print(infos['MemoryUsage'])  # Display memory usage of the CP engine
    print(infos['PeakMemoryUsage'])  # Display peak memory usage of the CP engine

    Regards

    Philippe



    ------------------------------
    --
    Philippe Refalo
    IBM ILOG CP Optimizer
    ------------------------------



  • 3.  RE: How to Find the memory (RAM) , CPU Usage when running docplex model

    Posted Tue December 08, 2020 05:45 AM
    Hi Phillipe,

    Thanks for the update.Do you have an any advise on my second question.To be specific if IBM cognos analytics product run in background we can simply see 'IBM cognos' service is running.For TM1 also same we can see relavant service.But for cplex I cannot see that a service called 'IBM cplex' is  there.Do we have a service running from any other name for cplex.

    Regards
    Suresh

    ------------------------------
    Suresh Abeyweera
    ------------------------------



  • 4.  RE: How to Find the memory (RAM) , CPU Usage when running docplex model

    Posted Mon January 22, 2024 02:49 PM

    Hello [User],

    To examine resource usage (RAM and CPU) when running a Docplex optimization model with the CPLEX engine in Python, you can retrieve performance details using the get_statistics() method. Here's an example:

    from docplex.mp.model import Model

    model = Model(name='my_model')
    # ... (Define your optimization model here)
    solution = model.solve()
    performance_details = model.get_cplex().get_statistics()
    print(f"Memory Usage: {performance_details['memory']} bytes")
    print(f"CPU Time: {performance_details['time']} seconds")

    To monitor CPLEX in Windows Task Manager, look for processes related to CPLEX or your optimization model under the "Processes" tab. The names may vary, but they typically consume CPU and memory resources.

    Feel free to reach out if you have more questions.

    Best regards,

    serverflake



    ------------------------------
    server flake
    ------------------------------



  • 5.  RE: How to Find the memory (RAM) , CPU Usage when running docplex model

    Posted Fri February 23, 2024 11:47 AM

    That's not true. There's no get_statistics() function. 

    The only function available is docplex.mp.model_stats.ModelStatistics.

    https://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.model.html?highlight=statistics#docplex.mp.model.Model.statistics



    ------------------------------
    Alexandre Gracia-Calvo
    ------------------------------