gams:how_to_reduce_model_generation_time

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

Both sides previous revision Previous revision Next revision | Previous revision | ||

gams:how_to_reduce_model_generation_time [2015/09/18 14:43] Jarungjit Parnjai |
gams:how_to_reduce_model_generation_time [2017/09/02 19:26] support |
||
---|---|---|---|

Line 1: | Line 1: | ||

===== How to reduce model generation time ===== | ===== How to reduce model generation time ===== | ||

- | If you want to reduce the model generation time then the below example might be helpful. The first example "Slow Execution" is poorly formulated. The second example "Fast Execution" gives suggestions on how to improve the model, when we consider the execution speed of assignment statements and model generation time. Keep in mind that when you use indexed statements, like loop and sum, then you might be able to restrict the traversing over indices to a subset of all indices by using subsets, as well as, the dollar control statement with an appropriate condition statement. Furthermore, McCarl Guide section [[http://www.gams.com/help/topic/gams.doc/userguides/mccarl/finding_where_excessive_time_is_being_used.htm|Finding where excessive time is being used]] and, especially, option [[http://www.gams.com/help/topic/gams.doc/userguides/mccarl/profile_3.htm|profile]], may be helpful when you are reducing the model generation time. | + | If you want to reduce the model generation time then the below example might be helpful. The first example "Slow Execution" is poorly formulated. The second example "Fast Execution" gives suggestions on how to improve the model, when we consider the execution speed of assignment statements and model generation time. Keep in mind that when you use indexed statements, like loop and sum, then you might be able to restrict the traversing over indices to a subset of all indices by using subsets, as well as, the dollar control statement with an appropriate condition statement. Furthermore, McCarl Guide section ''Finding where excessive time is being used'' and, especially, option ''profile'', may be helpful when you are reducing the model generation time. |

Line 31: | Line 31: | ||

); | ); | ||

- | * Test4 | + | * Test4 and Test5 are coupled |

Variable z,y(k,l); | Variable z,y(k,l); | ||

Equation e1 Test5 | Equation e1 Test5 | ||

Line 38: | Line 38: | ||

e5 Test8; | e5 Test8; | ||

- | * Test5 | ||

e1(k,l)$(ord(k)=ord(l)).. | e1(k,l)$(ord(k)=ord(l)).. | ||

z =G= sum((kk,ll,ii)$p3(kk,ii,ll) ,p3(kk,ii,ll)*(ord(kk)+ord(ii)+ord(ll)) ) | z =G= sum((kk,ll,ii)$p3(kk,ii,ll) ,p3(kk,ii,ll)*(ord(kk)+ord(ii)+ord(ll)) ) | ||

Line 93: | Line 92: | ||

); | ); | ||

- | * Test4 Use subset kl to avoid the comparison $(ord(k)=ord(l)) | + | * Test4 Use subset kl in e1 to avoid the comparison $(ord(k)=ord(l)) |

- | * to be performed several times | + | * to be performed several times |

+ | * Test5 Avoid repeating a calculation, hence, e2 defines x that is used in e1. | ||

Variable z, y(k,l), x; | Variable z, y(k,l), x; | ||

Equation e1 Test5 Avoid repeating a calculation (1 of 2) | Equation e1 Test5 Avoid repeating a calculation (1 of 2) | ||

Line 101: | Line 101: | ||

e4 Logical ordering of driving indices kl (sum(kl. k l)); | e4 Logical ordering of driving indices kl (sum(kl. k l)); | ||

- | * Test5 Avoid repeating a calculation | ||

e1(kl(k,l)).. z =G= x / (ord(k)+ord(l)) ; | e1(kl(k,l)).. z =G= x / (ord(k)+ord(l)) ; | ||

e2.. x =E= sum((kk,ll,ii)$p3(kk,ii,ll) ,p3(kk,ii,ll)*(ord(kk)+ord(ii)+ord(ll)) ); | e2.. x =E= sum((kk,ll,ii)$p3(kk,ii,ll) ,p3(kk,ii,ll)*(ord(kk)+ord(ii)+ord(ll)) ); |

IMPRESSUM / LEGAL NOTICE
PRIVACY POLICY
gams/how_to_reduce_model_generation_time.txt · Last modified: 2017/09/02 19:26 by support