Borrar filtros
Borrar filtros

Change constraints within optimization loop

16 visualizaciones (últimos 30 días)
Cedric Kotitschke
Cedric Kotitschke el 8 de Abr. de 2022
Respondida: xuechen el 20 de Jul. de 2024 a las 5:31
Hey,
I have an optimization problem in which the constraints depend on whether the design variable has changed or not (Single-Loop-Approach in RBDO if anyone is interested) .
Do you have any idea how to do this with fmincon?
I found a very extensive toolbox which has this optimization problem implemented but the code is very complex. However, I saw that their method is to pass an object in the nonlinear constraint function and the output function to update some flags which are used to compute the appropriate constraints.
Here is the output function (this function gets called in each iteration, corresponds to the option 'OutputFcn'):
function stop = outfun(x,optimValues,state,current_analysis)
stop = false ;
switch state
case 'init'
% Do nothing...
% Initial value is already saved in Histroy.X &.Score
% Update the flag signaling that a new point is about
% to be computed
current_analysis.Internal.Runtime.isnewpoint = true ;
case 'iter'
% Concatenate current point and objective function
% value with history. x must be a row vector.
History.Score = ...
[History.Score; optimValues.fval];
History.X = ...
[History.X; x];
% Update the flag signaling that a new point is about
% to be computed
current_analysis.Internal.Runtime.isnewpoint = true ;
case 'done'
% Do nothing
otherwise
% Do nothing
end
end
You can clearly see how the flag 'isnewpoint' is updated. It is set to false in the nonlinear constraints function.
This makes me wonder how this works. It seems this object can be updated from anywhere like it is a global variable. However, it is not. It doesn't appear blueish like global variables do and it is not defined as global anywhere. So how does this work?
Cheers
Cedric

Respuesta aceptada

Cedric Kotitschke
Cedric Kotitschke el 8 de Abr. de 2022
Found the answer:
the class of current_analysis is a subclass of the dynamicprops superclass and the properties are SetObservable

Más respuestas (1)

xuechen
xuechen el 20 de Jul. de 2024 a las 5:31
Hello, have you solved this problem? I am also confused about the Single-Loop-Approach. Can I ask you a few questions? Thank you.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by