I was writing a small model with e electricity suppliers and v electricity consumers. Everyone of the suppliers and consumers has their own load curve in a 15minutes resolution (which makes roughly 35 k timesteps in year).

My aim is to minimize distribution costs wich depend on the distance and other factors I have included.

Because I want to be able to scale up the number of consumers, I decided to slice the model into a given number p, each containing t timesteps, the model would solve at once.

I used code I found in this forum enabling a sequentual solving and now I am experiencing two things:

a) the building of the solving matrix takes a lot of time,

b) the post solving is very time consuming.

I would say, a model with 30 suppliers and 200 consumers and 1000 timesteps takes about 8 minutes to be build, 30 seconds to be solved and another 3 minutes to do the post solving. It also felt like the RAM would be filled more and more in each of the 35 loops. At least, I was expecting it to be emptied in between loops.

Some ideas on how I can speed up things would be appreciate it.

It really feels like the model should solve faster from my experience with way bigger models!

Thanks in advance,

Cheers!

Fred

This is my code:

Code: Select all

```
set Zeit(Zeit_Gesamt) /t00001*t35136/;
Alias (Zeit, t)
scalars optperiod 'Laenge des rollierenden Optimierungsintervalls' /1000/;
$eval tSlices ceil(card(Zeit)/optperiod)
SET tSlice / p1*p%tSlices% /
Periode(Zeit) 'dynamic subset of Zeit'
map(tSlice,Zeit) 'mapping of time slice to time steps';
Alias (Periode, p);
map(tSlice,Zeit) = (ord(tSlice)-1)*optperiod < ord(Zeit) and (ord(tSlice))*optperiod >= ord(Zeit);
option map:0:0:1; display map;
*
*###Subsets, Cost functions###
*
* ################
* # Variable #
* ################
positive variable Stromlieferung_RLM(t,e,v) 'In einer Zeitscheibe von E nach V gelieferte Strommenge';
positive variable Residualstrom(t,v) 'In einer Zeitscheibe vom Grundversorger an V gelieferte Strommenge';
* ######################
* # Objective Function #
* ######################
free variable z;
equation cost;
cost.. z =e= sum((p,e,v), Stromlieferung_RLM(p,e,v)*p_ges(e,v))+sum((p,v),Residualstrom(p,v)*p_residual);
* #################
* # Equations #
* #################
equation MaxErzeugung (t,e);
MaxErzeugung(p,e).. erz(p,e) =g= sum(v, Stromlieferung_RLM(p,e,v));
equation MaxVerbrauch_RLM (t,v);
MaxVerbrauch_RLM(p,V_RLM).. ver(p,V_RLM) =e= sum(e, Stromlieferung_RLM(p,e,V_RLM)) + Residualstrom(p,V_RLM);
* ########################
* # Modell-Parameter #
* ########################
Model Distribution 'WIP' / all /;
loop(tSlice,
p(Zeit) = map(tSlice,Zeit); display p, tSlice;
*slices of load curves that are needed for each period modelled
erz(p,e) = Erzeugung(p,e);
ver(p,v) = Verbrauch(p,v);
solve Distribution using lp minimizing z;
Strommengen_kum(e,v) = Strommengen_kum(e,v)
+sum(p$Stromlieferung_RLM.l(p,e,v), Stromlieferung_RLM.l(p,e,v));
);
```