gams:counting_the_number_of_equations_generated_by_a_specific_constraint

This shows you the differences between two versions of the page.

— |
gams:counting_the_number_of_equations_generated_by_a_specific_constraint [2007/08/09 15:56] (current) |
||
---|---|---|---|

Line 1: | Line 1: | ||

+ | ====== Counting the Number of Equations generated by a specific Constraint ====== | ||

+ | |||

+ | //Q: I wonder if there is a nice way to count the number of the equation that is is related to a specific constraint. For example, a gams expression that is:// | ||

+ | |||

+ | demand(j) .. sum(i, x(i,j)) =g= b(j) ; | ||

+ | |||

+ | //How can I count the number of equation generated by that equation? Is there any suffix or index I can refer to?// | ||

+ | |||

+ | If you use the limrow = 1 option, then the output of your gams model will include the first instance of every equation you have defined and include a message indicating the number of skipped rows also generated: | ||

+ | <code> | ||

+ | ---- demand =G= satisfy demand at market j | ||

+ | |||

+ | demand(new-york).. x(seattle,new-york) + x(san-diego,new-york) =G= 325 ; | ||

+ | |||

+ | (LHS = 0, INFES = 325 ***) | ||

+ | |||

+ | REMAINING 2 ENTRIES SKIPPED | ||

+ | </code> | ||

+ | |||

+ | Thus the constraint ''demand(j)'' generates three equations. | ||

+ | |||

+ | Another approach is to use the results of the ''profile'' option to get the number of generated equations. Below is an example, which writes the collected information of the trnsport model into a file ''eq.txt'': | ||

+ | <code> | ||

+ | $call 'gamslib trnsport' | ||

+ | option limrow=1,limcol=0, profile=1; | ||

+ | $include trnsport.gms | ||

+ | * get number of equations from profile | ||

+ | execute 'grep -i secs %system.ofile% |grep "EQUATION" >eq.txt' | ||

+ | </code> | ||

+ | The last entry of each line in ''eq.txt'' tells you the number of generated equations: | ||

+ | <code> | ||

+ | 74 execute 'grep -i secs C:\temp\xxx\t2.lst |grep "EQUATION" >eq.txt' | ||

+ | ---- 61 EQUATION cost 0.000 0.000 SECS 4 Mb 1 | ||

+ | ---- 63 EQUATION supply 0.000 0.000 SECS 4 Mb 2 | ||

+ | ---- 65 EQUATION demand 0.000 0.000 SECS 4 Mb 3 | ||

+ | </code> | ||

+ | |||

+ | |||

IMPRESSUM / LEGAL NOTICE
PRIVACY POLICY
gams/counting_the_number_of_equations_generated_by_a_specific_constraint.txt ยท Last modified: 2007/08/09 15:56 (external edit)