0

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: Criteria Parameters Optimization Simulation Results 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!

bmorvaj
  • 55
  • 1
  • 7
  • I assume you already have had a look at the Dymola User Manual? Volume 2, Chapter 3 is about design optimization. – matth Feb 18 '14 at 14:45

1 Answers1

0

I guess you are on the wrong tracks. You chose "x1" and "x2" for parameters to be optimized, but "x1" and "x2" are not defined as parameters in the model. Parameters are fixed during the simulation run.

If you want to vary time trajectories, you have to use the Optimization task "Trajectory Optimization"