Modeling with the solution pool tool

Problems with modeling
enriqueiglesias
User
User
Posts: 17
Joined: 2 months ago

Modeling with the solution pool tool

Post by enriqueiglesias » 1 month ago

Hi all GAMS users,

I have a production production problem with an objective function that consists in different summations (regarding setup, inventory, standby and energy costs) but right now for a certain purpose I am neglecting the last one. Based on the negligence of energy costs in the objective function, various optimal solutions for the production problem exist, as various changes in the sequence have no efects on the objective function at this point. Based on their individual sequence of machine states, the resulting solutions difer in energy costs and consequently in total costs (of course the variables and constraints related to energy are included in the model)

What I would like to do now is to storage a low number of different optimal solutions.

I have read the solution pool documentation and even try to include the code from the GAMS model library "soolmpool" but I receive the following error "symbol is not a set" and it seems like the problem is the "u" because there is where the pointer goes once I click the error message.

The problematic line:

Code: Select all

Alias (soln,s1,s2), (*,u);  
Since I do not really understand why the (*,u) is used I do not know how to fix this problem I am facing...

I hope I explained my self properly and that someone could give me some insights about how to solve my problem.

Best regards,


solmpool.gms
(11.06 KiB) Downloaded 18 times
Last edited by enriqueiglesias 4 weeks ago, edited 2 times in total.

User avatar
bussieck
Moderator
Moderator
Posts: 486
Joined: 3 years ago

Re: Modeling with the solution pool tool

Post by bussieck » 1 month ago

From your email it is not clear what issue you face. You just attached the standard model solmpool from the GAMS Model Library (https://www.gams.com/latest/gamslib_ml/ ... mpool.html). The alias (*,u) is used to initialize the parameter xcostX(soln,*) to 0. Since an assignment xcostX(soln,*) = is not possible, this model needs an alias to the universe *. I doubt that this is your problem. Perhaps you can send your model and show where the real issue is.

-Michael

enriqueiglesias
User
User
Posts: 17
Joined: 2 months ago

Re: Modeling with the solution pool tool

Post by enriqueiglesias » 1 month ago

Dear Michael,

Thanks for the fast response. I'm sorry, I send now my model where I have just added (after my whole model is defined) and modified the starting code from the soolmpool example and you can check the error message. I would say only thing I have done so far is tochange the model's variables for mines.
eoglsp_solpool.gms
(12.44 KiB) Downloaded 14 times

User avatar
bussieck
Moderator
Moderator
Posts: 486
Joined: 3 years ago

Re: Modeling with the solution pool tool

Post by bussieck » 4 weeks ago

Here is the corrected code. -Michael
eoglsp_solpool_mrb.gms
(12.65 KiB) Downloaded 39 times

enriqueiglesias
User
User
Posts: 17
Joined: 2 months ago

Re: Modeling with the solution pool tool

Post by enriqueiglesias » 4 weeks ago

Dear Michael,

Thank you so much for your help, time and consideration! I really appreciate it! I will explore more in order to display each solution results the way I want it.

Have a nice day!!!

enriqueiglesias
User
User
Posts: 17
Joined: 2 months ago

Re: Modeling with the solution pool tool

Post by enriqueiglesias » 4 weeks ago

Dear Michael,

Is there any way to know the cpu time that solver takes to solve the problem for the different optimal solutions?
I am having some hard times when treating with parameters and not variables...
For example, in order to calculate the energy costs (which depend of the value of the optimal variables and some fixed parameters) I have added a new constraint to the model (since I did not know how to treat with parameters in the $include readsoln.gms)

Code: Select all

energycostseq..
energycosts =e= sum((s,r,k)$((ord(s)>1)and(ord(r)>1)),lq(k,r,s)*pq(k)+lqp(k,r,s)*pqp(k)+lz(k,r,s)*pz(k) * ec(r));
(of course I have also created the parameter "energycostsx(soln)" and afer adding also "energycostsx=energycosts," I include it in the .gdx file with

Code: Select all

xcostX(solnpool,'energycosts','','','')       = energycostsx(solnpool); 
That is working as expected.

The problem is I cannot do it the same way with the parameter "time" (because it relies in the solver arribute "resusd"), and if try to treat the time the same way as I am doing with the other variables, even though I do not receive compilation errors, it is not showing and there is a moment where the SOLVE is aborted as you can see in the pic. (I have tried defining "time" as a parameter and as a variable with the same unsucessful results).

As always, thanks in advace.
eoglsp_solpool_mrb.gms
(13.2 KiB) Downloaded 13 times

enriqueiglesias
User
User
Posts: 17
Joined: 2 months ago

Re: Modeling with the solution pool tool

Post by enriqueiglesias » 3 weeks ago

Sorry, I have just realized I did not upload the picture of the message where it says it aborts the solve

solve aborted : Image

Best regards

enriqueiglesias
User
User
Posts: 17
Joined: 2 months ago

Re: Modeling with the solution pool tool

Post by enriqueiglesias » 2 weeks ago

Dear Michael,

Sorry to bother you again. I have to use the solution pool tool for many different scenarios, so I have include the original code inside a loop of the scenarios (after all the corresponding parameters for the scenarios have been defined). The problem is that in the generated .gdx file only the values of the last scenario are storaged.

Is there any way that I can storage the values of each scenario in the gdx file? even if they are storaged in different files (with the data from one scenario each) would be useful.

I have also tried just writting them down with the 'put' command but that only writes down the values of one of the solutions per iteration of the loop (and I need the values of more solutions, that's why I'm using the solution pool).

I hope you can give me some insights with this doubt too and thanks in advance,

Best regards.
data_test.txt
(497 Bytes) Downloaded 14 times
glsp_pool_inst.gms
(13.43 KiB) Downloaded 11 times
data_sce.txt
(2.3 KiB) Downloaded 15 times

Fred
Posts: 215
Joined: 3 years ago

Re: Modeling with the solution pool tool

Post by Fred » 2 weeks ago

Enrique,

In your latest example there are 4 solve statements. You loop over 2 scenarios and for every scenario you solve the model twice.
It seems that in readsoln.gms you are computing some sort of report parameter xcostX. You could give this parameter additional indices for scenario and 1st/2nd solve to store the results from all solves (note that you should not clear xcostX in that case).
You could also give the solnpool gdx files different names in the cplex.opt file (e.g. with a scenario and 1st/2nd Solve suffix) if you want to keep them all.

I attached a modified version of the gms file.
glsp_pool_inst_ff.gms
Attachments
glsp_pool_inst_ff.gms
(13.69 KiB) Downloaded 16 times

enriqueiglesias
User
User
Posts: 17
Joined: 2 months ago

Re: Modeling with the solution pool tool

Post by enriqueiglesias » 2 weeks ago

Dear Fred,

Thank you so much for your help. This is exactly what I wanted.

If asking one more thing is not too much.. is it also possible to know how much time it takes to the solver to reach each optimal solution? (the ones that I am storaging). If I include "time=model.resusd" and then I display it I just see the total time, and in the other hand, I do not know how I could include the time in the report parameter or in the gdx file (which storages the variables of every instance individually), but I do not know how to include parameters in this report...

Again, thank you for your help and time.

Post Reply