Archiver
User Posts: 7876
Joined: 4 years ago

Hello!

I am trying to do a simple example and I am New to GAMS.
I want to do a simple Power flow example in order to expand it later, i want GAMS to minimize the cost by choosing the cheapest generators.
My problem is that I want the load to change for every hour for my system, here is a 3 hour example and the error is marked in red.

HERE IS MY CODE:

\$TITLE pflow

Set t hours per day / t1, t2, t3 / ;
parameters
/t1 3
t2 5
t3 8/ ;
Scalar
Cost_diesel in â‚¬ per kWh / 2 /
Cost_pv in â‚¬ / 1.1 /

VARIABLES
*L(t),
X_g Diesel generator,
X_pv Domestic PV generation ,
Z Total cost of grid operation in â‚¬ per kWh for on hour;

EQUATIONS
OBJ Objective equation total cost of grid operation in â‚¬ per kWh ;

Load_balance.. X_g + X_pv -L(t) =E= 0 ;
149 Uncontrolled set entered as constant
OBJ.. Z =E= (X_g*Cost_diesel) + (X_pv*Cost_pv);

* Upper bounds
X_g.UP = 10 ;
X_pv.UP = 2 ;
* Lower bounds
X_g.lo = 0 ;
X_pv.lo = 0 ;
* Initial point
X_g.l = 0 ;
X_pv.l = 0 ;

MODEL pflow / ALL / ;
OPTION LIMROW = 100;
OPTION LIMCOL = 100;

loop(t, SOLVE pflow USING LP MINIMIZING Z) ;

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.

Archiver
User Posts: 7876
Joined: 4 years ago

Hi,

the programming problem was very basic, see new equation definition
and alias for the loop.

Still the problem as defined is unfeasible, you might want to check
its rational definition.

\$TITLE pflow

Set t hours per day / t1, t2, t3 / ;
parameters
/t1 3
t2 5
t3 8/ ;
Scalar
Cost_diesel in â‚¬ per kWh / 2 /
Cost_pv in â‚¬ / 1.1 /

alias(t,tt);
VARIABLES
*L(t),
X_g Diesel generator,
X_pv Domestic PV generation ,
Z Total cost of grid operation in â‚¬ per kWh for on hour;

EQUATIONS
OBJ Objective equation total cost of grid operation in â‚¬ per kWh ;

Load_balance(t).. X_g + X_pv -L(t) =E= 0 ;
*149 Uncontrolled set entered as constant
OBJ.. Z =E= (X_g*Cost_diesel) + (X_pv*Cost_pv);

* Upper bounds
X_g.UP = 10 ;
X_pv.UP = 2 ;
* Lower bounds
X_g.lo = 0 ;
X_pv.lo = 0 ;
* Initial point
X_g.l = 0 ;
X_pv.l = 0 ;

MODEL pflow / ALL / ;
OPTION LIMROW = 100;
OPTION LIMCOL = 100;

loop(tt, SOLVE pflow USING LP MINIMIZING Z) ;

hope this helps,
Roger
http://fnu.zmaw.de/index.php?id=7179&L=3

2014-10-16 12:44 GMT+02:00 Ivan Nordnes Dahlberg :
> > Hello!
> >
> > I am trying to do a simple example and I am New to GAMS.
> > I want to do a simple Power flow example in order to expand it later, i want
> > GAMS to minimize the cost by choosing the cheapest generators.
> > My problem is that I want the load to change for every hour for my system,
> > here is a 3 hour example and the error is marked in red.
> >
> >
> > HERE IS MY CODE:
> >
> > \$TITLE pflow
> >
> > Set t hours per day / t1, t2, t3 / ;
> > parameters
> > L(t) Load for each
> > /t1 3
> > t2 5
> > t3 8/ ;
> > Scalar
> > Cost_diesel in â‚¬ per kWh / 2 /
> > Cost_pv in â‚¬ / 1.1 /
> >
> > VARIABLES
> > *L(t),
> > X_g Diesel generator,
> > X_pv Domestic PV generation ,
> > Z Total cost of grid operation in â‚¬ per kWh for on hour;
> >
> > EQUATIONS
> > Load_Balance Maintane a stable grid,
> > OBJ Objective equation total cost of grid operation in â‚¬ per kWh ;
> >
> > Load_balance.. X_g + X_pv -L(t) =E= 0 ;
> > 149 Uncontrolled set entered as constant
> > OBJ.. Z =E= (X_g*Cost_diesel) + (X_pv*Cost_pv);
> >
> > * Upper bounds
> > X_g.UP = 10 ;
> > X_pv.UP = 2 ;
> > * Lower bounds
> > X_g.lo = 0 ;
> > X_pv.lo = 0 ;
> > * Initial point
> > X_g.l = 0 ;
> > X_pv.l = 0 ;
> > * Load(s).l = 0 ;
> >
> > MODEL pflow / ALL / ;
> > OPTION LIMROW = 100;
> > OPTION LIMCOL = 100;
> >
> > loop(t, SOLVE pflow USING LP MINIMIZING Z) ;
> >
> > --
> > "gamsworld" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > To post to this group, send email to gamsworld@googlegroups.com.
> > Visit this group at http://groups.google.com/group/gamsworld.
> > For more options, visit https://groups.google.com/d/optout.

Rofice
User Posts: 27
Joined: 4 years ago

Hi,
The problem with the equation is You have to enter constant here. You can do this by summing or specifying certain for example
1. Load_balance.. X_g + X_pv -sum(t,L(t)) =E= 0 ;
2. Load_balance.. X_g + X_pv -L('t1') =E= 0 ;

Otherwise GAMS dont know which element to select from the domain t until you specify function like sum,prod etc..

Regards

gamze
User Posts: 1
Joined: 1 year ago

Dear colleagues,

I am trying to find weights of some methods' s result for each observation. I have 62500 observations and 6 methods. I have the true value of the observation and my objective is to minimize the difference between true value and results of the weighted sum of methods. My positive variable is wij (i= observation, j=method) and summation of it should be equal to 1. I would like to find, for example, for first observation is w11, w12,w13,w14,w15,w16 son on.
image.png
I have tried this code but it does not work
option nlp=SNOPT;

sets
i observations /1*62500/
j method /1*6/;

table y_t(i,j)

\$call =xls2gms r=a1:g62500 i=technic.xlsx o=technic.inc
\$include technic.inc
;

parameter y(i) /
\$call =xls2gms r=a1:b62500 i=target.xlsx o=target.inc
\$include target.inc
/;
scalar
c/1/;

variable z;
positive variable w(i,j);

equations
objective
subject;

subject..
sum ((i,j), w(i,j))=e=c;

objective..
loop((i,
sum(i, sqr(y(i)-sum(j, w(i,j)*y_t(i,j)))/62500=e=z;
solve opt using nlp minimizing z;
));

model opt/all/;