Currently, I’m trying to set a variable at certain time steps to a specified value. Unfortunately what I have so far only works for a single step.
The code that I have is as follow:
From MATLAB via the $LOADIDX the following values are set:
extrapower = 25
extrapower_value = 5
In GAMS:
Pgrid.fx(t) $(ord(t) = extrapower) = extrapower_value;
where t is my step in the simulation from 1 till 96
I know that ord(t) can only take a single input, but I don’t know how to formulate it for multiple. What I would like to achieve is as follow:
If there are boundaries:
From MATLAB via the LOADIDX the following values are set:
extrapower = [25 26 27 28 45 46]
extrapower_value = [5 6 5 6 5 6]
In GAMS:
Pgrid.fx(t) (??? = extrapower) = extrapower_value
Or if there are no boundaries:
From MATLAB via the LOADIDX the following values are set:
extrapower = []
extrapower_value = []
In GAMS:
Pgrid.fx(t) (??? = extrapower) = extrapower_value
Does anybody know how to do this via constraint or is there a simpler method possible to set certain values? The equation itself is modeled as follow:
Pgrid(t) =e= Pinv(t) - Pload_fc(t);
I already found out how to remove the boundary. This can be done in the following way
From MATLAB via the LOADIDX the following values are set:
extrapower = []
extrapower_value = []
constraint_allowed = 0 (1 is allowed/0 is not allowed)
In GAMS:
Pgrid.fx(t) (ord(t) $(constraint_allowed = 1) = extrapower) = extrapower_value;
So the only question I have left how to do this for multiple boundaries, which may vary in size:
From MATLAB via the LOADIDX the following values are set:
extrapower = [25 26 27 28 45 46]
extrapower_value = [5 6 5 6 5 6]
constraint_allowed = 1 (1 is allowed/0 is not allowed)
In GAMS:
Pgrid.fx(t) (??? $(constraint_allowed = 1) = extrapower) = extrapower_value;
Thank you for your reply, I implemented the solution partly. To be able to control the values in the subset I replaced it with multiple parameters. Therefore my solution is as follow:
MATLAB
extrapower = zeros(96,1) ; % set to zero to prevent boundaries from actually being used and to match size of set
extrapower([5 10 15 20], = 1 ; % positions you want fixed
extrapower_value = zeros(96,1); % initialise to match size of set
extrapower_value([5 10 15 20], = [3 4 5 5]; % values at these positions
GAMS
set t /1*96/
parameters
extrapower(t)
extrapower_value(t)