【问题标题】:GAMS Model and implementing parameters and variablesGAMS 模型和实现参数和变量
【发布时间】:2021-12-08 03:15:45
【问题描述】:

我有一个想要回答的问题,我写出了每个要求,但我很难在 GAM 中实现它。我对 GAMS 很陌生,不确定每个变量的去向。我哪里错了? enter image description hereenter image description here


    
Sets   
       i   pump capacity 
       j   pump rate  / 1-10 / ;
Parameters
       a(i)  capacity of plant i in cases
         
       b(j)  pump capacity 
        ;
Table  d(i,j) 
    PUMP    MAXIMUM (GAL/MIN)   COST ($/GAL/MIN)    FROM WELL
1   1100                         0.05          1
2   1100                    0.05    2
3   1100    0.05    3
4   1500    0.07    1
5   1500    0.07    2
6   1500    0.07    3
7   2500    0.13    1
8   2500    0.13    2
9   2500    0.13    3
10  2500    0.13    3
;



Variables
     x(i,j) 
     z        ;
Positive variables x ;
Equations
     cost        
     supply(i)   
     demand(j)    ;
cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j)) ;
supply(i) ..   sum(j, x(i,j))  =l=  a(i) ;
demand(j) ..   sum(i, x(i,j))  =g=  b(j) ;
Model transport /all/ ;
Solve transport using LP minimizing z ;

【问题讨论】:

    标签: gams-math


    【解决方案1】:

    这行得通:

    Sets   
           i pump plans   / 1*10 /
           k wells /1*3/;
    Parameters
    WL(k) "limits on wells on GAL/MIN"
           /1 3000,
            2 2500,
            3 7000/
    
    MaxGM(i) "limits on pump plans on GAL/MIN"
           /1 1100,
            2 1100,
            3 1100,
            4 1500,
            5 1500,
            6 1500,
            7 2500,
            8 2500,
            9 2500,
            10 2500/
    PlanCost(i) "plan costs per GAL/MIN"
           /1 0.05,
            2 0.05,
            3 0.05,
            4 0.07,
            5 0.07,
            6 0.07,
            7 0.13,
            8 0.13,
            9 0.13,
            10 0.13/ 
             ;
             
    display MaxGM, PlanCost;
    Table d(i,k) "States if plan i is located in well k"
        1   2   3  
    1   1
    2       1
    3           1
    4   1
    5       1
    6           1
    7   1
    8       1
    9           1
    10          1
    ;
    
    scalar MinOutput /10000/;
    
    
    Variables
         x(i) 
         z        ;
    Positive variables x ;
    Equations
         cost        
         supply(i)
         supply2(k)
         demand    ;
    cost ..        z  =e=  sum((i), PlanCost(i)*x(i)) ;
    supply(i) ..   x(i)  =l=  MaxGM(i) ;
    supply2(k) ..   sum(i$d(i,k), x(i))  =l=  WL(k) ;
    demand ..   sum(i, x(i))  =g= MinOutput ;
    Model transport /all/ ;
    Solve transport using LP minimizing z ;
    
    display x.l;
    

    结果是:

    1 - 1100
    2 - 1100
    3 - 1100
    4 - 1500
    5 - 1400
    6 - 1500
    9 - 2300

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      • 1970-01-01
      相关资源
      最近更新 更多