I was wondering if anyone who has used the Optimization Library in Dymola has been able to utilize the RealtimeOptimization function without having explicit plant constitutive equations to input into the criteriaFunction? Specifically, I am trying to use some of my model's states as the criteria function, but when I input y[1] := mymodel.state;
with or without quotes around the state, Dymola rejects the function. Any thoughts would be very helpful. Thank you.

- 13
- 1
- 6
2 Answers
You could try adding outputs (Modelica.Blocks.Interfaces.RealOutputs) to the top level of the model and then linking these to the states by using Modelica.Blocks.Sources.RealExpression blocks.
Then when using the optimisation function goto the criteria page and use the Select button and select these outputs to add them as criteria.

- 475
- 2
- 10
-
The criteria page creates optimization criteria for the solver, but not for the criteria function. The function itself does not have access to the model, except as noted by Andreas. – E Heller Apr 30 '13 at 14:35
It is not possible to have access to model variables inside a function. You have to provide the values of the variables through the inputs to the function. The task RealtimeOptimization is aimed to be called during the simulation of a Modelica model. The criteria function has the defined inputs nTuners, nCriteria, tuners[nTuners]. You can add additional input variables, see the Example Optimization.Tasks.RealtimeOptimization.Examples.Example02.RunSampled and the record UserData in the function Optimization.Tasks.RealtimeOptimization.Examples.Example02.criteriaFunc02. By these additional variables you could transfer some state variables into the critiera function.
Maybe we can assist you, if you provide more information about your setting. I am the main developer of the Optimization library in Dymola.

- 16
- 2
-
Thank you Andreas. I am trying to form a closed-loop control for my modeled system using the optimization Realtime function. I have three system states I want to control within Min/Max limits, and two inputs, also with limits. The performance criteria is a target for one of the inputs. There is an additional input to the system that is an external reference (not controllable). Your thoughts would be most appreciated. – E Heller Apr 30 '13 at 15:45
-
After trying to input my criteria function in the Optimization window (GUI), I receive an error that the function I have defined is illegal. Must the criteria function define the criteria as explicit functions of the tuners? I cannot define my model states as clear functions of the tuners I am using. Is there a way to just use C[1] := myinput1; ? – E Heller May 01 '13 at 01:01