Opened 11 years ago
Last modified 7 years ago
#2736 accepted discussion
Final Constraints for Optimization missing
Reported by: | Vitalij Ruge | Owned by: | Mahder Alemseged Gebremedhin |
---|---|---|---|
Priority: | normal | Milestone: | Future |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: | Mahder Alemseged Gebremedhin |
Description
Currently it's not possible to formulation final constraints in the optimization.
In the moment we support path constraints with Otimica Extension.
Real a,b,c,d,e; ..... constraint a*b + c/d < e
In Optimica it's possible to write for final constraints.
Real a,b,c,d,e; ..... constraint a(finaTime)*b(finalTime) + c(1.0)*d(finalTime) < b(1.0)
where finalTime is a real parameter 1.0, which is unknown sometimes.
Note: stopTime not equal finalTime!
There some issues with different time point and the case if finalTime is unknown.
It seem like the currently way in Modelica is to set marker via (Custom) annotations
see e.g. http://www.ep.liu.se/ecp/096/018/ecp14096018.pdf
It's would be nice to have something like
Real a,b,c,d,e; ..... constraint a*b + c/d < e annotation(finalConstraint = true)
The issue is that a*b + c/d < e is an equation and the annotation going missing in the BackEnd.
Alternative it should be possible to write
Real a,b,c,d,e; Boolean f (finalConstraint = true); ..... equation f = a*b + c/d < e;
However custom annotations not really finished yet!
Therefore, I prefer for the first prototype similar implementation like constraint with
Real a,b,c,d,e; ..... equation .... final constraint a*b + c/d < e; constraint ...
Change History (13)
comment:1 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
when terminal()
sounds like native solution for me.
In the constraint environment I will get the error:
Error: Parse error: Only function call expressions may stand alone in an algorithm section
for
setCommandLineOptions("+g=Optimica"); getErrorString(); loadString(" optimization foo(objectiveIntegrand = (x)^2) input Real u(min = -10, max = 10); Real x(min = -5, max = 10); equation der(x) = u; constraint when terminal() then x == 7; end when; end foo; ");
when time >= const
would be nice solution for time points constraints, too.
Then we would only have problems with periodic constraints formulation like
x(startTime) == x(stopTime) or f(x(startTime), x(stopTime),startTime,stopTime) == 0
comment:4 by , 10 years ago
Other simply idea can be to add new function
optimization foo(objectiveIntegrand = (x)^2) input Real u(min = -10, max = 10); Real x(min = -5, max = 10); equation der(x) = u; constraint optimizationFunctionForTimeConstraints(x == 7,time == stopTime); end foo;
comment:5 by , 10 years ago
Priority: | high → normal |
---|
Since r22103 we can use annotation for final constraints terms.
Example:
model testFinalCon Real x1(start = 1, fixed = true); Real x2(start = -1, fixed = true); input Real u; Real final_con1(min = 0, max = 0) annotation(isFinalConstraint = true); Real final_con2(min = 0, max = 0) annotation(isFinalConstraint = true); Real cost annotation(isLagrange = true); equation der(x1) = x2*u - x1; der(x2) = x1 + u; final_con1 = x1 - 2; //0 <= x1 - 2 <= 0 for t = tf final_con2 = x2 - 3; cost = u^2; end testFinalCon;
However I think the constraint-environment is more user friendly. I hope in the future we can support when terminal() in constraint-environment.
comment:6 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:7 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:12 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:13 by , 7 years ago
Milestone: | 1.12.0 → Future |
---|
The milestone of this ticket has been reassigned to "Future".
If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.
If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".
In both cases, a short informative comment would be welcome.
Why not just use
when terminal()
?