Context: I have an optimisation problem, which minimises locations of electric charge stations. Therefore I need a constraint, which calculates the state of charge of one vehicle at a time stamp. I struggle with modelling that constraint.
I have something in mind which looks like this:
for all vehicles and times stateofcharge[vehicle][time] = stateofcharge_start + ((sum up to time)gainedpower[vehicle][time] - (sum up to time)used power[vehicle][time])
I don't know how to put that into code, I tried but it keeps me giving errors.
You could start with
int nbVeh=6;
int horizon=10;
range vehicle=1..nbVeh;
range time=1..horizon;
range time0=0..horizon;
float stateofcharge_start[vehicle]=[1,2,3,4,5,6];
dvar float+ stateoecharge[vehicle][time0];
dvar float+ gainedpower[vehicle][time];
dvar float+ usedpower[vehicle][time];
subject to
{
forall(v in vehicle)
stateoecharge[v][0]==stateofcharge_start[v];
forall(v in vehicle,t in time)
stateoecharge[v][t]==stateoecharge[v][t-1]+gainedpower[v][t]-usedpower[v][t];
}