Releasing RAM memory after finishing with an execution


I want to clear the memory used by AIMMS after running an execution. I delete the GMP but still huge amount of RAM is occupied by AIMMS after the run. So I have to close and open the AIMMS to have a fresh start (i.e. with a clear RAM memory). Is there anyway to clean the RAM used by AIMMS after the execution so I do not need to close and open it again and again?

Thanks in advance. 


12 replies

Userlevel 5

Hi @afattahi Maybe something here will help you?

 

https://how-to.aimms.com/Articles/108/108-kb08-reduce-memory-use.html#reduce-memory-usage

https://how-to.aimms.com/Articles/170/170-memory-in-use.html#analyzing-memory-used-by-gmps

Hi @Jess Es , thank you for the links.

I use Empty AllIdentifiers; and still, I cannot free up the RAM.

Just to give an idea I provide you with some numbers:

When I am finished with the optimization, I check the RAM and AIMMS is occupying around 7GBs. Then I delete the GMPs and the memory is reduced to 5.8 GBs. Then I empty all identifiers and the memory is reduced to 5.2 GBs. 

Unfortunately, I cannot reduce the RAM any further, unless I close and open the AIMMS. 

I would like to run several independent procedures consecutively and I need a fresh RAM at the beginning of each one.

Userlevel 5

Afattahi, did you try the cleanup and/or rebuild functions? It seems that you have a lot of inactive data.

@mateusarakawa, I used Empty, Cleanup, and Rebuild functions on AllIdentifiers and except Empty function, the other two had no effect on the used RAM by AIMMS. 

I also checked the Identifiers Cardinalities section and I did not see any major memory usage by any identifier. 

Userlevel 4

@afattahi , may I ask why you need to reset the RAM for each of your runs ? 

 

AIMMS does not release all of the memory directly to the OS right away as it is anticipating you will need/use that memory again, so it holds on to the memory for subsequent runs. If we know what you are trying to do, we could suggest an approach.

@mohansx, Here is what I want to do:

I am solving a LP energy model for several consecutive years (e.g. 2020,2021 ,… ,2025). This problem consists of planning (inter-year) and operation (inter-year) variables and constraints. I use the barrier method of Gurobi and since the problem is relatively huge, it takes many hours to solve the crossover phase. So, I divided the problem into two parts:

First, I solve the planning problem (i.e. matrix of 5 years) using the barrier method (without crossover). This problem takes around 90GB of RAM. I have 32GB installed, so around 60GB of committed memory is virtual RAM.

Second,  I set planning variables as ”nonvar” and solve the operation problem with barrier and crossover. The crossover is necessary at this stage as I need the value of dual variables (i.e. shadow prices and reduced costs). At this stage, I use Asynchronous solving to solve all years in parallel, since crossover only uses one core of CPU. 

I want to empty the RAM after solving the first problem, so I wouldn’t need virtual RAM in the second stage. I already delete the first GMP and it helps. I was wondering if I can provide more free RAM for the second stage. 

 

 

Userlevel 3

If Gurobi spends a lot of time in the crossover phase then you should consider setting its ‘Barrier Convergence Tolerance’ option to a smaller value (closer to 0) to get a more accurate solution from the Barrier algorithm (at the cost of some more time used by Barrier). This might sometimes reduce the time spent in crossover.

It might be a good idea to print the Gurobi log (for the original model with the long crossover) and share it as it might give some insight in what Gurobi is doing. To print the Gurobi log you should set the following options:

  • Solvers General option 'Solver listing messages' to 'All'
  • Gurobi option 'Output file' to 'Yes'

@Marcel Hunting, thanks for the tips. I have tried tightening the crossover tolerance and also use the Robust option, but I did not notice much improvement. 

I solved a lighter version of the model and attached the log file of Gurobi. I would appreciate if you can tell me some tips on reading the solver log. Note that I cannot reduce the matrix range due to nature of this energy system problem.

Userlevel 3

@afattahi, the barrier algorithm shows a sub-optimal termination which seems to indicate that the final solution found by barrier is not very accurate, but I see no way to improve this by using Gurobi options.

The matrix, objective and rhs contain some very small values (in absolute sense), with 6e-17 for the rhs as the most extreme one (and it also looks strange). Not sure why you think that you cannot reduce the matrix range. By using units (or scaling factors) in AIMMS one can often make the matrix range smaller.

For example, if you give a variable a scaling factor/unit of 100 then all coefficients in the matrix corresponding to that variable will be multiplied by 100 underneath before the model is send to the solver. So a value of 1e-8 will then become 1e-6. (Note that the solution value for that variable will then become a factor 100 times smaller.)

For example, if you give a variable a scaling factor/unit of 100 then all coefficients in the matrix corresponding to that variable will be multiplied by 100 underneath before the model is send to the solver. So a value of 1e-8 will then become 1e-6. (Note that the solution value for that variable will then become a factor 100 times smaller.)

@Marcel Hunting Thank you for the tip. I changed some units and scaling factors, but there are many relevant variables in each coefficient that changing the scale of one will affect almost the whole matrix. Therefore, it is difficult for me to use scaling factors in a controlled way. 

@afattahi , may I ask why you need to reset the RAM for each of your runs ? 

AIMMS does not release all of the memory directly to the OS right away as it is anticipating you will need/use that memory again, so it holds on to the memory for subsequent runs. If we know what you are trying to do, we could suggest an approach.

 

@mohansx, Here is what I want to do:

I am solving a LP energy model for several consecutive years (e.g. 2020,2021 ,… ,2025). This problem consists of planning (inter-year) and operation (inter-year) variables and constraints. I use the barrier method of Gurobi and since the problem is relatively huge, it takes many hours to solve the crossover phase. So, I divided the problem into two parts:

First, I solve the planning problem (i.e. matrix of 5 years) using the barrier method (without crossover). This problem takes around 90GB of RAM. I have 32GB installed, so around 60GB of committed memory is virtual RAM.

Second,  I set planning variables as ”nonvar” and solve the operation problem with barrier and crossover. The crossover is necessary at this stage as I need the value of dual variables (i.e. shadow prices and reduced costs). At this stage, I use Asynchronous solving to solve all years in parallel, since crossover only uses one core of CPU. 

I want to empty the RAM after solving the first problem, so I wouldn’t need virtual RAM in the second stage. I already delete the first GMP and it helps. I was wondering if I can provide more free RAM for the second stage. 

 

 @mohansx I think still I need to free up the committed ram memory. I would appreciate it if you can provide me with any recommendations? 

 

Userlevel 4

@afattahi , like I mentioned in https://community.aimms.com/aimms-developer-12/releasing-ram-memory-after-finishing-with-an-execution-586#post1498, AIMMS is not going to release all of the memory unless you close it. There is no way around here. 

You could try saving a case file after your phase 1, close and reopen AIMMS, load case file and solve your phase 2 to check how much memory is being used in phase 2. I am not completely sure how Windows handles virtual memory, if the required memory is less than the actual memory available (32 gb), will it still use the virtual memory enabled ? I expect the OS to allocate the physical RAM before having to use the virtual RAM. 

Read about cases here: https://how-to.aimms.com/Articles/258/258-save-a-case-from-aimms-procedure.html#save-a-case-from-an-aimms-procedure

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator