The UFZ services GitLab and Mattermost will be unavailable on Monday, July 4 from 06:00 AM to 08:00 AM due to maintenance work.

Commit 1058ddc5 authored by Markus Millinger's avatar Markus Millinger
Browse files

Finished adapting gamsVarCreate and gamsVar, now all works over the function

parent 52d64d26
%!PS-Adobe-3.0 EPSF-3.0
%%Creator: (MATLAB, The Mathworks, Inc. Version 9.5.0.944444 \(R2018b\). Operating System: Windows 10)
%%Title: ../fig/productionSecS1.eps
%%CreationDate: 2020-09-16T13:33:35
%%CreationDate: 2020-09-16T15:46:55
%%Pages: (atend)
%%BoundingBox: 0 0 750 450
%%LanguageLevel: 3
......
This diff is collapsed.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BENOPT (BioENergy OPTimisation model)
% Copyright (C) 2012-2020 Markus Millinger
%
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%
%
% Contact: markus.millinger@ufz.de
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Creation of GAMS variables
%
function gamsVarOut = gamsVarCreate(name,inputVar,x,y,type)
function gamsVarOut = gamsVarCreate(name,inputVar,x,y,z,type)
% gamsVarOut = gamsVarIn;
% gamsVarOut(end+1) = setfield(name,name);
% inputVar
if contains(type,'param')
if isnumeric(x)
x = strsplit(num2str(x));
elseif isnumeric(y)
y = num2str(y);
end
gamsVarOut.(name).uels = {x, y};
gamsVarOut.(name).name = name;
gamsVarOut.(name).type = 'parameter';
gamsVarOut.(name).form = 'full';
gamsVarOut.(name).val = inputVar;
if isnumeric(y)
y = strsplit(num2str(y));
end
if isnumeric(z)
z = num2str(z);
end
gamsVarOut.name = name;
gamsVarOut.type = 'parameter';
gamsVarOut.form = 'full';
gamsVarOut.val = inputVar;
if isequal(size(y),[1 1]) %if y is not a vector, make uels one dimensional
gamsVarOut.uels = {x};
elseif isequal(size(z),[1 1]) %if z is not a vector, make uels two dimensional
gamsVarOut.uels = {x, y};
else
gamsVarOut.uels = {x, y, z};
end
elseif contains(type,'set')
gamsVarOut.(name).name = (name);
gamsVarOut.(name).type = 'set';
gamsVarOut.(name).uels = {inputVar};
gamsVarOut.name = name;
gamsVarOut.type = 'set';
if isequal(size(inputVar),[1 1])==0
gamsVarOut.val = inputVar;
end
if isequal(size(y),[1 1]) %if y is not a vector, no uels
gamsVarOut.uels = {x};
elseif isequal(size(z),[1 1]) %if z is not a vector, make uels two dimensional
gamsVarOut.uels = {x, y};
gamsVarOut.form = 'full';
else
gamsVarOut.uels = {x, y, z};
gamsVarOut.form = 'full';
end
elseif contains(type,'scalar')
gamsVarOut.(name).name = name;
gamsVarOut.(name).type = 'parameter';
gamsVarOut.name = name;
gamsVarOut.type = 'parameter';
gamsVarOut.val = inputVar;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BENOPT (BioENergy OPTimisation model)
% Copyright (C) 2012-2020 Markus Millinger
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%
% Contact: markus.millinger@ufz.de
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Creation of GAMS variables
%
function gamsVarOut = gamsVarCreate2(name,inputVar,x,y,z,type)
% gamsVarOut = gamsVarIn;
% gamsVarOut(end+1) = setfield(name,name);
if contains(type,'param')
if isnumeric(x)
x = strsplit(num2str(x));
end
if isnumeric(y)
y = strsplit(num2str(y));
end
if isnumeric(z)
z = num2str(z);
end
if isequal(size(y),[1 1]) %if y is not a vector, make uels one dimensional
gamsVarOut.uels = {x};
elseif isequal(size(z),[1 1]) %if z is not a vector, make uels two dimensional
gamsVarOut.uels = {x, y};
else
gamsVarOut.uels = {x, y, z};
end
gamsVarOut.name = name;
gamsVarOut.type = 'parameter';
gamsVarOut.form = 'full';
gamsVarOut.val = inputVar;
elseif contains(type,'set')
gamsVarOut.name = name;
gamsVarOut.type = 'set';
gamsVarOut.uels = {inputVar};
elseif contains(type,'scalar')
gamsVarOut.name = name;
gamsVarOut.type = 'parameter';
end
end
......@@ -32,6 +32,35 @@ col = setCol;
titleVector={'S1 Base','S2 MoreH2','S3 NoLand','S4 CCSBase','S5 CCSMoreH2','S6 CCSNoLand'};
titleVector2={'Base','MoreH2','NoLand','CCSBase','CCSMoreH2','CCSNoLand'};
%%
%% Sorting techs into sectors for plotting
g.TS=cell(1,s.numSectors);
for j=1:s.numSectors
g.TS{j}=transpose(find(g.techsectors(:,j)==1));
end
[row,cols]=find(g.techsectors(:,6:9)==1);
g.TStrans=transpose(unique(row));
[row,cols]=find(g.techsectors(:,1:9)==1);
g.TSall=transpose(unique(row));
[row,cols]=find(g.techsectors(:,1)==1);
g.TSindTH=transpose(unique(row));
[row,cols]=find(g.techsectors(:,2)==1);
g.TSghdTH=transpose(unique(row));
[row,cols]=find(g.techsectors(:,3)==1);
g.TShhTH=transpose(unique(row));
[row,cols]=find(s.powerByprodInit(:)==1);
g.TSconvEL=transpose(unique(row));
[row,cols]=find(g.techsectors(:,4)==1);
g.TSconvELgrid=transpose(unique(row));
[row,cols]=find(g.techsectors(:,5)==1);
g.TSconvTH=transpose(unique(row));
% %%
% for scenario = 1
......
......@@ -405,4 +405,5 @@ for i=1:s.numTech
s.cap1(1:s.plantLifeTime(i),i) = linspace(s.plantCap(i),0,s.plantLifeTime(i));
end
s.cap0 = s.cap1(1:s.runTime,1:s.numTech); %Necessary if plantLifeTime > runTime (otherwise matrix is too large in gamsRun)
end
\ No newline at end of file
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment