I am trying to optimize (minimize) variable "emissions" using the ModelOptimization function in the library optimization for dymola using the following code:
model opt
parameter Real electricity=999;
Real x2(start=0);
Real x1(start=0);
Real usageEle;
Real usagePV;
Real emissions(start=0);
Modelica.Blocks.Sources.TimeTable solarThermal(table = [0,400;3599,400;3600,200;7199,200;7200,400;10799,400;10800,200]);
Modelica.Blocks.Sources.TimeTable heatDemand(table = [0,300;3600,300;7200,300;10800,300]);
equation
x2*electricity+x1*solarThermal.y=heatDemand.y;
0=x2*electricity+x1*solarThermal.y - heatDemand.y;
total=x2*electricity+x1*solarThermal.y - heatDemand.y;
usageEle=x2*electricity;
usagePV=x1*solarThermal.y;
der(emissions)=0.13*x2*electricity;
end opt;
The problem is that it doesn't respect the bounds that I set for variables x1 and x2 which need to be from 0 to 1 (1 to 100%). Emissions will be minimal if the solarThermal is used over electricity.
This are pics of settings:
As you can see x1 and x2 go roughly from -0.1 to 1.1 when they should max go from 0 to 1. Do you know what is the reason for this?
Any help would be greatly appreciated because I am kinda stuck and don't know how to proceed. Thank you!