Opened 10 years ago

Last modified 3 years ago

#3197 new defect

Better optimization support in OMEdit

Reported by: Per Östlund Owned by: Adeel Asghar
Priority: normal Milestone: Future
Component: OMEdit Version: trunk
Keywords: Cc: Vitalij Ruge

Description

There's currently no support for doing an optimization in OMEdit, except for calling the optimize API manually from the command line. This needs to be made more user friendly so that normal users can do optimizations in OMEdit, either by adding a button in the toolbar or some other way.

Attachments (1)

Option in OMEdite for dyn. optimization.JPG (27.4 KB ) - added by Vitalij Ruge 10 years ago.
It would be nice to have setups like

Download all attachments as: .zip

Change History (13)

comment:1 by Per Östlund, 10 years ago

Cc: Vitalij Ruge added

Add Vitalij as Cc in case he has some input for how to best handle this.

by Vitalij Ruge, 10 years ago

It would be nice to have setups like

comment:2 by Vitalij Ruge, 10 years ago

In the optiozation we have a other scope,
new settings menu like in the figure would be helpful

e.g.
Generate optimization problem -> +gDynOpt
Collocation Points -> -optimizerNP 1 or 3

comment:3 by Vitalij Ruge, 10 years ago

For pure button we would need something like
OMC Flags: +gDynOpt
simulationsflags: -s optimization
and other default value for Number of Intervals e.g. 100

comment:4 by Vitalij Ruge, 10 years ago

but I prefer the solution with new setup button more

comment:5 by Rüdiger Franke, 10 years ago

There find many different model-based applications that one might want to run from OMEdit, optimization only being one of them. There even find different ways for the treatment of optimization problems, which require different user dialogs.

On the other hand side Modelica enables the automatic generation of parameterization GUI's, like the one attached, out of Modelica models or parameter records.

It would be great if OMEdit improved its generic support for parameter GUI's such that specific user dialogs can be added by library developers in the form of Modelica packages.

comment:6 by Adeel Asghar, 10 years ago

I saw the optimize API in ModelicaBuiltin.mo. Its same as simulate so why not use the Simulation Dialog? Can you provide an example of doing optimization on a model via command line (a mos script)?

Btw, I noticed that optimize API sets the following flags and doesn't seem to unset them,

Flags.setConfigBool(Flags.GENERATE_SYMBOLIC_LINEARIZATION,true);
Flags.setConfigEnum(Flags.GRAMMAR, Flags.OPTIMICA);
Flags.setConfigBool(Flags.GENERATE_DYN_OPTIMIZATION_PROBLEM,true);

in reply to:  6 comment:7 by Vitalij Ruge, 10 years ago

Replying to adeas31:

I saw the optimize API in ModelicaBuiltin.mo. Its same as simulate so why not use the Simulation Dialog?

simulation and optimization are different tasks. It can be confused someone to press the simulation button to start optimization. (Nice to have)

Btw, I noticed that optimize API sets the following flags ...

The flags are processed in Backend, which make the Backend slow and must be remove if the user want swich his task(simulation,optimization), which is currently a little hidding in the options.
I guess it's would be help a lot if the compiler flags(Check box) for Flags.GENERATE_DYN_OPTIMIZATION_PROBLEM can be add in the simulation options and the "method" "optimization" is only enable if this checkbox is enable.

In addition we have some other helpful compiler flags and simulation flags dependent on model (for optimization or simulation). Would it possible extends the simulation options for some Compiler flags, like tearinMethode....

Of the other hand the the approach of Rüdiger is very smart. If we don't want flood OMEdite with buttons and flags.
I guess we will need something like

annotation(__OMEdit(setCommandLineOptions(...));

Replying to rfranke:
or? Much like mos-script.

For example I'm not motivated tip the fowling line

setPostOptModules("relaxSystem,inlineArrayEqn,constantLinearSystem,simplifysemiLinear,
solveLinearSystem,removeSimpleEquations,encapsulateWhenConditions,reshufflePost,
tearingSystem,partlintornsystem,countOperations,inputDerivativesUsed,
calculateStrongComponentJacobians,calculateStateSetsJacobians,detectJacobianSparsePattern,
generateSymbolicJacobian,generateSymbolicLinearization,CSE,removeUnusedFunctions,removeConstants");
getErrorString();

in a edit box, which is necessary to use currently implementation of the cse in optimization.


comment:8 by Adeel Asghar, 10 years ago

Yeah we can have a separate button but just reuse Simulation Dialog.
can you provide a mos-script with optimization example? I need to know what exactly is required to run an optimization model.

comment:9 by Vitalij Ruge, 10 years ago

setCommandLineOptions("+gDynOpt");
getErrorString();

loadString("

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;

");
getErrorString();

simulate(testFinalCon, numberOfIntervals=100, tolerance = 1e-08, stopTime = 5,simflags="-s optimization");
getErrorString();

comment:10 by Vitalij Ruge, 10 years ago

Do you planning support for Optimica in OMEdit?

comment:11 by Vitalij Ruge, 10 years ago

for Optimica we will need
setCommandLineOptions("+g=Optimica +gDynOpt");

comment:12 by massimo ceraolo, 3 years ago

Now there is good GUI support for dynamic optimization in OM.
In addition to being more user-friendly, it supports final constraints, which optimica does not, and this is a very important feature.
I've prepared some docu on how to make DO with OM using annotations (i.e. OMEdit and its GUI), which is currently being revised by Vitalij, then it will hopefully go on-line.

When this occurs, I think this ticket can be closed.

Note: See TracTickets for help on using tickets.