## Storing solution

Problems with syntax of GAMS
Rofice
User
Posts: 24
Joined: 2 years ago

### Storing solution

Dear all,

I am facing problem in formulating syntax for storing (recording) the frequency (how many times the same solution is found) of solution. In other words, in the attached model sensitivity analysis is performed and after each iteration, a new solution is found. What I want is to systematically rank the solution based on their frequency.

Kind regards,
Rofice
toy problem.gms

Renger
Posts: 419
Joined: 3 years ago

### Re: Storing solution

Hi
YOu could do as follows:

Code: Select all

``````alias(i,ai), (j,aj);
parameter frequency(i,j,ai,aj) Frequency of solutions;
frequency(i,j,ai,aj)\$(ord(i) = 1)  = sum(k\$(not sameas(i,ai) and not sameas(j,aj)), report(k,i,j)*report(k,ai,aj)) ;
display frequency;
``````
this gives you

Code: Select all

``````index = 1
3           4

1.2       1.000       3.000
2.2       4.000       2.000
``````
Or:
(1,1) (2,3) = 1
(1,2) (2,4) = 3
...

For the ordering, you probably are better off doing this in excel...

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

Rofice
User
Posts: 24
Joined: 2 years ago

### Re: Storing solution

Dear Renger,

Thank you very much for the formulation.

kind regards,
Rofice