QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 17799|回复: 15
打印 上一主题 下一主题

【英文教程】GAMS使用小技巧和小陷阱

[复制链接]
字体大小: 正常 放大

1253

主题

440

听众

-586

积分

复兴中华数学头子

  • TA的每日心情
    开心
    2011-9-26 17:31
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    自我介绍
    数学中国网站(www.madio.cn)是目前中国最大的数学建模交流社区

    邮箱绑定达人 优秀斑竹奖 发帖功臣 元老勋章 新人进步奖 原创写作奖 最具活力勋章 风雨历程奖

    群组越狱吧

    群组湖南工业大学数学建模同盟会

    群组四川农业大学数学建模协会

    群组重庆交通大学数学建模协会

    群组中国矿业大学数学建模协会

    跳转到指定楼层
    1#
    发表于 2009-11-14 04:50 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta |邮箱已经成功绑定
    GAMS Tips and Tricks
    ; i2 o$ Q; @2 S+ S, vBelow, a (random) list of useful tips and tricks for GAMS users is given. This list is oriented at graduate students who start using GAMS but already know the general syntax. The list is constructed largely as the result of concrete questions asked by GAMS users. Experienced users will find many well-known modelling features, but may find some items they didn’t know yet. 4 n& O) j+ a) N
    In principle, almost everything can be found in the GAMS User Guide, which (among other interesting documentation) can be found on http://www.gams.com/docs/document.htm. Some new features are not in the official User guide yet; you can get these when you follow the very useful advanced GAMS course by Bruce McCarl.
    / \0 `+ i( f/ P: w; kIf you have any (good new) tips or tricks, or if you have found a bug / ambiguity in the existing tips and tricks, send an email to Rob.Dellink@wur.nl.
    7 T7 x$ S% ~6 t: L4 B________________________________________
    ( D+ r0 `/ {8 _4 ^' b1. Browse through the GAMS mailing list archive; it contains a lot of usefull tips and tricks (including some of the hints below): http://www.gams.de/3docs/gams_archives/external.html gives a summary of the main topics and the full archive can be browsed at http://www.listserv.gmd.de/archives/gams-l.html  5 S  T  C5 M+ ]; S7 q" f. U" o+ n
    {Contributed by Rob Dellink} 0 f3 J0 A6 W; i" p
    ________________________________________
    ; _# b/ i) m) V2. GAMS comes with a library of 160 models; take a look at these models when building your own model (the library can be found on the hard disk in the MODLIB subdirectory and on the GAMS homepage).  1 u) I! X) o: r; H5 }; ^, \3 B
    {Contributed by Rob Dellink} ) f9 Y& |$ M8 a1 M5 w9 M! r% G
    ________________________________________ , p$ r- @0 p. w  H3 F% i. \8 K
    3. First solve a model using zero iterations to check whether the benchmark (i.e. the base data you provide) is replicated by the model. This is to make sure that there are no errors in the calibration of the model.  
    9 P2 l) k2 D& V4 V<modelname>.iterlim = 0; $ v% d: {% A3 X" h7 b
    solve <modelname> using <solver> maximising <optimand>;
    " G6 |; D- s9 o" l<modelname>.iterlim = 2000; % q0 {! Y* e' p& C! Z
    {Contributed by Rob Dellink} 9 D6 T2 O% }* G
    ________________________________________ : P( g' D1 }. W9 F; t6 Z- E; L' |$ H
    4. Use the abort statement if the model specification is incorrect, that is, if you end up with a solution that does not satisfy some condition you know that has to be satisfied; for example, if the benchmark does not replicate, you can use:  
    : U2 l1 z+ r# E) Q9 P- C7 pABORT$(<modelname>.OBJVAL GT 1E-6) "DATA CALIBRATION ERROR! LARGEST ERROR: ", <modelname>.OBJVAL;
    + }9 N) V( q& y' A! n: [* V4 vOr in case you know (by Walras’ law) that the level of C2 has to equal the level of X2: * a, W- C" [3 R
    ABORT$((C2.L-X2.L)**2 gt 1E-20) "Walras law not obeyed!";
    $ @5 ]9 ]' U) z+ `0 c{Contributed by Rob Dellink}
    : g5 j- J. g, `" }' i1 ^+ a9 J________________________________________
    ! \. Y; H- K& E% E" S/ L5. Always check whether your model has been normally completed and found an optimal solution:  ! C( y7 p$ B" ?2 t4 S& ~) ~! R( F
    DISPLAY <modelname>.MODELSTAT, <modelname>.SOLVESTAT; % ?: f( B( r& f/ c6 f  L1 b. B
    Both should equal 1 if the model is linear; solvestat should equal 2 for non-linear models. You can use an abort statement if one or both is incorrect: / v# E: K* _; A
    ABORT$(<modelname>.MODELSTAT <> 1) "Model not normally completed", <modelname.MODELSTAT;
    3 M  K$ I4 z" [, [5 H% lABORT$(<modelname>.SOLVESTAT <> 2) "No local optimum found", <modelname.SOLVESTAT;
    + ^* u# Q8 N" \& T+ ~" N2 B{Contributed by Rob Dellink}
    8 l# j+ A" c1 e& H& b) A________________________________________ $ |% b, N! L& x8 E' {
    6. Provide starting values! If you have some clue about ‘good’ values for your variables, give that information to the GAMS model. It will avoid the often-found ‘zero-solution’, that an optimum is found where all variables equal zero. Moreover, it will help in avoiding infeasibilities.  
    ( e! y+ A$ }0 x0 d( ~, SYou could compare specifying a model without starting values as asking a person what "bank" means without telling them what language it is. Where should that person start looking? "Bank" can mean many different things across different languages…To provide starting values, give the name of the variable, add ".L" and then specify the indices of theat variable (remember that ".L" should come before the indices!):  
    0 P* E. I  q9 W# F- F. OVARIABLE X(J); % n* C& `. C# l8 |6 K2 h/ k/ H
    X.L(J) = 1; ) f2 O, M0 |- I
    X.L("1") = 2;
    ) C& a0 F4 z3 ~5 ?3 o" r< … insert model declaration etcetera here … > 9 N6 ?8 N* F1 r; K" q
    {Contributed by Rob Dellink} ! D& f  F  b- g
    ________________________________________
    % s* ]  M4 e- M% B$ y7. If you want to comment out several lines, use the $ontext and $offtext commands. Make a habit of starting your GAMS files withsomething like the following:  
    & s8 \4 F8 D) U: B$TITLE The name of my model, version xx
    , `8 b, |# c+ i- n6 ~) P# i$ontext & V: Q8 M4 q: L# I  I$ |$ j4 Y6 h
    version: xx 7 ^. f2 Q; z0 G! \$ n. d) I- t
    date: dd-mm-yy
    , ?5 d) |: b& qauthor of this version: initials $ M( _6 P$ x# b' Z( q2 }6 B1 F; T
    based on: previous version x
      X6 p' y0 H/ scharacteristics: …
    : x( W" U, u$ Tnew in this version: compared to version x
    # H( x0 j  ~, _& o3 q0 C& [5 g3 W4 Cproblem1: none?!
    % n3 d8 M3 |1 A; |* T# nnote1: feature y still has to be included
    8 r( a, R* c0 k! T% o0 p( Lnote2: feature z may need to be modified
    ) Z& j: \% E! t; I, G* j$offtext
    , f5 }" @2 N0 _7 h7 a8 |8 `$ E{Contributed by Rob Dellink}
    ( e. \# B* w9 \# R! K7 p________________________________________
    4 k) s) D$ Q. G6 A; {8. You can limit the output listing file by including the following statements:  
    1 \' ^4 W+ F, w3 M$offsymxref  ' v. S2 W9 K' d5 m" `
    {This stops the print of a complete cros-reference list of symbols }
    8 s; G1 l* p1 ^) C$ q2 W: |# k0 r$ I$offlisting
    8 u5 {9 L( {) n$ ~{This stops the echo print of the input file} * h( M) F3 E; y- O. y/ ?
    option limcol = 0;
    * W1 ]: a8 O. H; D5 ^3 q& n{This stops the print of the column listing}
    * b7 \3 }: T* |& R) m& t; |- Xoption limrow = 0;
    0 l/ y- d" Y7 k5 E{This stops the print of the equation listing}
    8 F: _$ B8 T, k' @/ S{Contributed by Rob Dellink} - O+ t( I  D) @  n: O2 C7 R: D
    ________________________________________ & ~1 x% k6 h: o- y
    9. If you fix the level of a variable (variable.fx = …), don’t forget to free it again:  
    & j: |. V' G  L; d# ^5 S! Pvariable.lo = -inf;
    8 S7 w$ A. h! Z$ P0 W* H) Vvariable.up = inf; " p- v/ K6 T# [" w# @7 Y" I4 k0 r
    {Contributed by Rob Dellink} : {+ i6 M* s, K3 G- J) Y
    ________________________________________ ; H; @9 h; `2 ]- G
    10. When you are debugging your model, try shortening the execution time by using $exit to exclude the last part of your code: $exit will stop the GAMS execution, command after this line (perhaps including elaborate sensititivty analysis) will not be executed.  3 ~% t0 ^  |& b& h* w6 [4 B* B+ ]
    {Contributed by Rob Dellink} 1 J* z) |: C0 k" [
    ________________________________________
    4 x5 |3 L2 f, x) \' @11. If you have infeasibilities, there are (at least) three things you can do to aleviate your problems: 8 W2 P4 e# ~5 @/ K
    1. Remove all unneccesary upper and lower bounds and fixed variables from your code; # x1 w0 K. }+ Q, D
    2. Provide better starting values; 5 o! w, u8 S3 v7 ^& B
    3. Change equalities into inequalities (it is always a good thing to use inequalities in stead of equalities).   
    + z7 V7 D' B1 _9 r9 y6 t{Contributed by Judit Szonyi and Rob Dellink} 6 |4 g5 w! T- [1 D
    ________________________________________
    * C1 w/ V$ J3 g% c, d12. Learn to use vector notation instead of scalars; it makes larger models much more campact:  & A, ^+ P% e, j7 A
    SETS J Sectors /1,2/; * V, s2 C- t9 G* h5 G
    VARIABLES Y(J) Production;
    - O* r: S0 |0 f8 ]8 @7 gInstead of:
    ) c7 ]" D& k, e# L- T7 T- sVARIABLES Y1 Producer 1
    3 c1 C, t) j" c, z1 I; S! k5 Z- KY2 Producer 2;
    6 Q: }# F$ o2 jFor two sectors, this does not make much difference. But imagine writing out 60 sectors or more. It is much easier to use the vector notation from the start, when your model is still small, than to have to rewrite it when you enlarge the model.
    % ?3 b: |, H/ u, s' K) s{Contributed by Rob Dellink} * ~: v9 M+ @2 s7 O1 ~
    ________________________________________
    8 o4 F2 B) @- ]' r* E13. You can use some identifiers of sets in put statements:set element label: <setname>.tl (useful in loops)set element associated text: <setname>.te(index)  
    ' F4 B( r& h2 N- t% lset associated text: <setname>.ts
    , R. v$ i7 M. {, hExample:
    / J, H1 q, Z6 ~- u: Wfile out /"results.out"/; put out; % K. U1 z# x7 Y: J" k; b
    set i associated text of set /i1 first element, i2 second element, i3/;
    2 p% w; H) S% n7 |0 y! t" i" ]put i.ts /; ' ?- r3 W- m# v% s" n: y* S0 z
    loop(i, put i.tl, i.te(i) /);   w. F9 ?: Q5 R% E+ a9 X
    The resulting file results.out will look like: 1 s6 H) R; H' _3 m6 e  x0 ]+ ]! q
    associated text of set , F. W5 @1 o, V: m4 F3 U4 r
    i1 first element 6 d1 P2 l/ x. I) o& n+ n7 c
    i2 second element % t& d, ^5 e6 @) k; A
    i3 I3
    8 U$ @' Q7 t" j{Contributed by Rob Dellink}
    ' V4 m! L( D" U! s9 ]' \# F________________________________________ 3 N- j& y8 n% [7 R+ p
    14. To get a good insight of the impacts of a parameter value on the model results (i.e. a sensitivity analysis), build a loop of solves for different parameter values; for example:  * Z7 B3 u7 k& H
    SET RANGE /iter0*iter10/; $ I5 [+ s. T& z9 p& V/ f, o
    SCALARS 4 S: ]  `+ Y" Z+ Y. _
    COUNT
    , ]" {9 m2 j! S- b7 h) {4 xLOWEST /0.1/
    0 E0 a% l: X" e9 ~2 o+ b, ]HIGHEST /0.9/; 5 t  ~% {* u: q7 R5 P. _3 ^
    PARAMETER XVALUE(RANGE) Parameter subject to sensitivity analysis
    " `/ w( c6 @! `" Q2 e7 uRESULTS(RANGE) Model results;
    ) a, S6 y  r, h& s< … insert model declaration etcetera here … >   X( I; Q( k6 q, w, x  r! \
    LOOP(RANGE,
    " S/ a$ ^' v5 B; v" ]) lCOUNT = (ORD(RANGE)-1)/(CARD(RANGE)-1); 1 l: D, }+ X5 i; J( A
    XVALUE(RANGE) = (1-COUNT)*LOWEST + COUNT*HIGHEST;
    4 o5 J' |1 W6 X. r+ o) s0 XSOLVE <modelname> USING <solver> MAXIMISING <optimand>;
    1 D6 Y& X* |) `0 T. x- L9 sRESULTS(RANGE) = …; + F( j, x' j  q  f3 z; q6 y" B! s
    ); 2 |% Y" C$ B( z0 ]# k5 W0 a1 J
    DISPLAY RESULTS; 1 r, z: o; h7 Z2 V2 s, b" T
    {Contributed by Rob Dellink}
    2 Z& t2 Q: E3 }& u________________________________________
    , [+ C8 v( G" \7 m15. How to get information on your screen in run-time? If you run several simulations within the same GAMS model (for instance, you do a loop of solves), you can  ; y4 a: q) g& |6 v. M+ J' h
    display "%system.filesys%/"; * L. X( o- a7 Q/ q4 T9 n7 @
    file screen /'con'/;
    7 i# r' I1 ?4 V/ t  pLOOP(t,
    & Q- n) m: y! ^4 N+ ]1 C< … include commands here … > / k" u5 r4 L: z+ c& ~$ L  U
    putclose screen 'The current value of index t is ',t.tl/;
    - @* K" ], O. q: Z; H* n, W);
    & }, s, t' L; |; ~) fNote: this may not work properly on a Unix or Windows NT platform.
    ! z1 n( q$ _' K& c/ A6 H0 XIf you use the GAMS-IDE, make sure that the DOS window is visible (select File / Options / Execute and choose ‘Normal’ for the DOS window). : }6 Y8 Y. h, Y4 p, H$ W
    {Contributed by Rob Dellink}
    4 ?$ Z  `( ]/ d7 y; }9 J________________________________________
    + B4 ~  C* `, i- h8 r$ n4 s16. If you want to get graphs of model results right after the model solve, take a look at the GNUPLOT utility which is available on the Internet (you can access it from the GAMS homepage); you’ll have to install this free utility separately.  3 {+ \7 t. |, G
    {Contributed by Rob Dellink}
    % P% {: B  J" q# B: ]________________________________________
      s! A4 V" a8 _/ x! U9 L( X17. Many users know the $include command to include pieces of GAMS code, but if you want to pass a parameter to the file that is to be included, use the $batinclude command.  
    4 K- k! _  F$ s5 m$BATINCLUDE FILES.INC "versionX" " w/ q7 `3 M# b( Z2 e
    and FILES.INC may look like:
    , }; y1 E5 z- r, X$ M& C) _$ R* s$CALL 'MD %1' 0 v5 j7 i9 M5 c2 h* l1 G
    FILE results /"%1\results.out"/; ! m5 I( O/ E0 e) l
    SET Version /%1/; . {, @2 S' K$ g: A0 ]
    When running the program, "%1" will be automatically substituted by "versionX". In this example, a subdirectory ‘versionx’ will be made and output directed to the file results will be written to the file ‘results.out’ in this subdirectory; finally, a set with only one element "versionx" is declared.
    . Y' ~) t- A6 A1 A3 ?+ l1 M{Contributed by Rob Dellink}
    " ]  e5 M; }" b) K________________________________________
    # C1 N' M2 z6 `; Z, y# d6 s18. If you have a model that costs a lot of time to calculate, then think about using the save and restart feature. This is especially handy if you have solved your model and are thinking about ways to organise the output. You caan run your model, save the work files from this run and restart from these workfiles for output handling. For example, if you have a GAMS-file (say, part1.gms) in which the data is read, the variables and equations are specified and your model is solved, then save the workfiles as, say, model1. Then, write the output handling code in a separate file (say, part2.gms), using the restart option. If you want to change anything in part2.gms, you do not have to solve the model again, you can just include the workfiles. This can save a lot of time (especially for larger models) and you can play around with how you want your output organised at little cost.
    0 B  Z) h0 o8 Q4 o$ p" c3 u6 K8 \) s  C
    Note that this save and restart feature can also be handy in other circumstances, like saving after solving a base scenario and then solving several scenarios using the restarted base. The code in the example above looks like this:  
    7 ?5 F% E  W. M$ d9 @GAMS part1 s=model1 6 h1 @1 P# {3 }) {' D, H1 H0 V8 ^0 O
    GAMS part2 r=model1 , ~# R. B5 m  a" G5 ?4 }. _
    {Contributed by Rob Dellink}
    4 K5 u& \$ ?" m% [. A, S; a________________________________________
    3 [6 Z5 }8 I# v6 w* N7 S. U  t' C  P19. In GAMS version 2.50 on newer, you can direct output to an Excel file via the XLimport, XLexport and XLdump routines; see http://nash.colorado.edu/tomruth/xllink/xllink.htm for more details. Alternatively, you could use put statements to make output file 'manually' (see the GAMS user guide for more details).  
      b7 r8 J1 `; i! D+ }, [! u{contributed by Erik Schmieman and Rob Dellink} - V: ^8 O5 |/ b+ s/ t
    ________________________________________
    5 J& D2 c' R/ B( D  X' N+ t( f1 I20. When using multidimensional datasets with a restricted number of allowed elements, you can use dynamic sets or set mapping to limit the set elements. The following example gives a full GAMS program that shows the dynamic sets and mapping.  
    & @# n* d  ^4 {8 u2 d- }0 l, t5 J$title A ** illustration of using dynamic sets
    1 C# u& e8 h8 c) |5 d$ontext
    + B$ l# |( T& h" Z! G6 XThis small example illustrates how one can limit the number of elements
    5 o- J3 \' N( s& e& F8 W7 \that are used in parameters by using either dynamic sets or set mapping.
    : s$ L1 ]1 ~2 T' l/ J8 F. i& @6 D+ D9 WIn this case, both procedures give the same results. ( _2 \0 r- [  H3 |- C- e
    The example also show how the dynamic sets can be used.
      `8 \. B3 ^# A( [1 K4 g$ e$offtext " f: l# J5 }( n  d
    sets 3 @6 ~1 K' N) c  O' h
    x /x1*x3/ % H# J$ A& K5 t
    y /y1*y4/
    / L6 S, \# y% c+ A- k9 Sxx(x) + a8 Z3 K8 b' \* i) r) B
    yy(y) 3 N1 b: L; {& v/ n4 n: {( h& r7 I
    xy(x,y);
    * M, Q( p6 A6 o$ w$ xparameter
    7 N: i' Y* O' ~a(x,y) the basis from which you retrieve the non-zero elements;
    " C' e$ p6 m+ I1 j*Suppose you know the values of a 8 x5 D/ i" V: v$ l$ y5 ~
    a(x,y) = 1; , V  {# x4 G5 Y4 L8 c; w
    a('x1',y) = 0;
    ( c( P  E: B6 e& Ma('x2','y2') = 0; * R+ _7 t8 O2 z4 [. V$ M4 Z  X
    a('x2','y3') = 0; 1 x$ D. t( V& l  N: n8 f$ I
    a('x2','y4') = 0;
    4 q$ D2 V, \0 |3 z% R5 ^a('x3','y2') = 0; . a# T2 Z% V5 o
    *Determine the dynamic sets * L# \- m% m9 T5 w8 r$ B: ]
    xx(x) = yes$(sum(y, a(x,y)) ne 0); / J5 S7 r. U3 M) ^3 D
    yy(y) = yes$(sum(x, a(x,y)) ne 0);
    % E+ j( c$ w* f: t" f" A' h9 q
    xy(x,y) = yes$(a(x,y) ne 0);
    - c  ^* @8 q8 [# Q) b* The same set with only non-zero elements could be retrieved through mapping
    ( B6 C5 z$ F% v" ^7 m& Bset yx(x,y) /x2.y1, x3.(y1,y3*y4)/; / p3 H' n+ c* n' E5 W( A5 u
    display x,y,a,xx,yy,xy,yx;
    ( o! U& ?; N/ X* H6 R3 m6 k2 |parameter 5 I# V: E7 i8 l2 Y& ~/ I$ R5 H
    b(x,y) the whole set with values regardless of zeros in a 3 D; o( U3 `* I8 k8 H& U
    c(x,y) parameter b corrected for non-existent x
    ' e* w5 l* P5 x8 G- w  a+ {- p# Sd(x,y) parameter b corrected for non-existent y
      B# x: D7 r" p+ Y( M1 N: te(x,y) parameter b corrected for non-existent x and y * _. Y# B' y# O# u
    f(x,y) parameter b for only existent elements based on dynamic set xy
    5 J- ?3 t% J' D/ @( e+ Ag(x,y) parameter b for only existent elements based on mapped set yx ' A% o/ C& K( m
    h(*,*) parameter b using the dynamic set xy 4 Z6 g' V  _8 q: _
    sumx(y) parameter h summed over x; 3 F8 m) p( s6 A$ g' C7 A; z
    b(x,y) = 1; ) j$ r0 y. o) `3 U
    c(xx,y) = 1; 3 W7 P# @$ O6 b1 b% d" d& D( U
    d(x,yy) = 1;
    7 {; W. @% v: [/ t: se(xx,yy) = 1;
    , v% r( m! \0 C. u! l& \f(x,y)$xy(x,y) = 1;
    ! c, @- J' d- z8 `* X' Wg(x,y)$yx(x,y) = 1; + H7 T% v' O1 }1 X1 |6 z7 M
    h(xy) = 1; + p. B7 V- W3 ?; b( _) j
    sumx(y) = sum(x, h(x,y));
    9 m% e+ l: |4 X1 C2 W3 rdisplay b,c,d,e,f,g,h,sumx;
    7 i0 M0 i# D; h/ L. F' W{Contributed by Rob Dellink and Erik Schmieman} ' J" q) L4 y3 S7 {9 D
    ________________________________________ ) @' J+ ~3 v7 i2 O- o
    21. If you want to have an equation where you divide the righthand side by another variable, you may encounter ‘division by zero’ errors. Suppose you have the equation    O7 n% x1 q( O+ T" I$ ]
    vv1(x,y).. v1(x,y) =e= a(x,y);
    1 \/ D8 s2 z1 ~, J- }- u+ Mvv2(x,y)$(a(x,y) ne 0).. v2(x,y) =e= rhs/v1(x,y); 5 k- g$ c: w! @
    Note that the second equation can only be made conditional upon the parameter a, not on variable v1. - b  S' X9 H6 [5 }
    In this straighforward case, you can solve the error as follows: 8 ?0 o) O1 F" P  @" o" J* b* z5 {& j
    vv1(x,y).. v1(x,y) =e= a(x,y); ; w2 ~( A8 }  @$ V* x+ z
    vv2(x,y)$(a(x,y) ne 0).. v2(x,y)*v1(x,y) =e= rhs;
    1 k$ H' d# ]3 \5 p{Contributed by Rob Dellink} ; u, D) D- u+ z3 W# L% ]
    ________________________________________
    8 q: |, |! O) i0 \" _" p6 s+ o22. If you want to build multisectoral Computable General Equilibrium models, think about using the MPSGE subsystem to GAMS. See the GAMS homepage, the homepage of ‘MPSGE-guru’ Tom Rutherford, or contact Rob Dellink.  . L6 C% d$ [' d( @
    {Contributed by Rob Dellink} 9 x7 g- d  N2 ?  }
    ________________________________________ 3 v5 f5 \0 w. u! r& u
    23. When doing mathematical programming where there is a chance of obtaining a non-
    + H; v* N# g% x  i! u* l) Iunique solution, it makes sense to do "near-optimal solution space" analysis. 9 O. n6 }2 c2 Y! H- [
    Basically what you do is after finding the solution, rerunning the model with a 6 V- h( Q5 y8 M5 _
    lower bound on the initial objective variable of e.g. 99%, 97.5%, or 95% of the " e8 k& Y7 s6 w7 T& |
    optimal value and using a variety of choice variables as new objectives, both
    ) `4 _/ W5 |- Z2 a) r+ n$ _% y4 ^minimising and maximising their values. This provides you with a set of 3 V6 g; \, ^* w/ c: T
    solutions that are very close to the optimal value.
    ) t: R- Q" N3 J' E5 t5 K1 g; E
    + H/ @# f' k3 XThe lower bound on the initial objective variable (in case of a minimisation / K/ h1 q% J# t0 q. f
    problem this is obviously an upper bound) should depend on the level of
    9 v5 r: u$ x! d! C2 Avariability you find in the "near-optimal solution space".
    ! L# x" _+ h# A& x) Y9 P6 Q9 i- t4 o0 Q3 y: T$ R+ H  L+ n0 k
    Let me refer to two articles:
    7 n" F8 U0 g9 e" I9 U- BMakowski, D., E.M.T. Hendrix, M.K. Van Ittersum and W.A.H. Rossing (2000)
    4 x6 K  i3 G& a* J0 ~Ecological Modelling 131:65-77. 8 B4 ]# v) T& C2 G
    and " `# |2 ~3 X& |2 V& Z% A2 Z. l
    Chapter 7 in my book: Kruseman, G. (2000) bio-economic modelling for ; w  y- @9 I$ w3 F# U9 T
    agricultural intensification. Mansholt Studies 20, Wageningen: Mansholt ( d+ }- }2 x+ J' e: L9 C& O: b
    Institute with Bakhuys publishers. : E6 a8 Z: I; V& _+ L! w) h4 |  x

    $ G/ s. }0 Q- w& F$ K6 d3 c4 V* O"near-optimal solution space" analysis is fairly ** to do in GAMS and it
    2 }# x- o; e$ u6 D0 agives you a lot of information about the stability of the model and the ! l0 E8 j4 R+ s
    variability of choice variables.   ( J8 L6 ~$ f% b. ?+ _, [! ]8 d$ A  _5 V
    See GAMS example  ( B( k. P, h5 D9 e8 d; W
    {Contributed by Gideon Kruseman} ' y& L+ I' m" M3 U4 t
    ________________________________________ 8 S% a; j( E1 Z/ H5 h4 Q7 y4 M6 O
    24. One user of the GAMS reader misspecified the capital equation in a neo-classical growth model as follows.  5 _. }- C: `6 u  {& f) D8 b
    He used    K(t) =E= ((K0$ord(t)=1) + K(t-1)*(1-delta) + I(t); 8 _( G. D$ c( I" F. u- N) g4 B" u
    instead of   K(t) =E= (K0$(ord(t)=1) + K(t-1)*(1-delta) + I(t);  9 N3 J; e1 ~! `" G
    Can you find the difference between the two? The impact is enormous. I was surprised that the top specification did not give an error message. 2 h6 q" `( f; h* u) W  \7 h/ g  f
    The lesson to be learnt: always be careful with those brackets. I love them because they force you to think very precisely about what you want to model.  
    , |4 I$ b4 Q8 s$ ^7 p8 S0 h; d{Contributed by Rob Dellink}
    $ w! ~/ b1 w5 F% B4 f8 `4 a+ z________________________________________
    6 ~; g& s0 w- K25. When you model equations that contain lags or leads, e.g. EQ1(t).. A(t+1) =E= A(t)+B(t);, and you don't restrict this equation, you will calculate A(t+1) also for the last period t. Since this next period A is not within the model horizon, you are not interested in it and hence the calculation is unnecesary. You can save computing time if you restrict the function not to calculate the after-horizon period: ! E4 O* T: f1 L5 [
    EQ1(t)$(ord(t) le card(t)-1).. A(t+1) =E= A(t)+B(t);  . }  s& l) D4 T. l" B1 L$ E
    Use the constraint both on the definition and declaration of the equation!   Q$ y( H- E2 F. J6 @
    This is especially relevant if the model is large and the equation is relatively difficult (e.g. a lot of summing and multiplication).
    , b# a# h% A: R# Z. \/ l" ?{Contributed by Muhammad Al-Salamah}
    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持3 反对反对0 微信微信

    0

    主题

    4

    听众

    18

    积分

    升级  13.68%

    该用户从未签到

    自我介绍
    呵呵 学化工的 做系统工程 跟数学打交道的机会太多了 努力学习各种建模和解模方法 请大家多多关照
    回复

    使用道具 举报

    1

    主题

    4

    听众

    14

    积分

    升级  9.47%

    该用户从未签到

    自我介绍
    一个路过者!
    回复

    使用道具 举报

    gssdzc 实名认证       

    0

    主题

    2

    听众

    941

    积分

    升级  85.25%

    该用户从未签到

    群组兰州大学数学建模协会

    回复

    使用道具 举报

    5#
    无效楼层,该帖已经被删除
    6#
    无效楼层,该帖已经被删除
    Silverry        

    1

    主题

    9

    听众

    571

    积分

    升级  90.33%

  • TA的每日心情
    开心
    2019-7-25 16:46
  • 签到天数: 57 天

    [LV.5]常住居民I

    自我介绍
    建模
    回复

    使用道具 举报

    8#
    无效楼层,该帖已经被删除

    2

    主题

    7

    听众

    124

    积分

    升级  12%

  • TA的每日心情
    郁闷
    2013-10-9 21:50
  • 签到天数: 38 天

    [LV.5]常住居民I

    自我介绍
    建模国二

    群组数学建摸协会

    回复

    使用道具 举报

    0

    主题

    7

    听众

    705

    积分

    升级  26.25%

  • TA的每日心情

    2017-5-7 16:58
  • 签到天数: 366 天

    [LV.9]以坛为家II

    邮箱绑定达人 社区QQ达人

    群组2012HIMCM培训群组

    群组第四届数学中国美赛实

    群组第三届数模基础实训

    群组高数系列公益培训

    群组物联网工程师培训

    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2024-4-24 20:40 , Processed in 0.569810 second(s), 96 queries .

    回顶部