Effacer les filtres
Effacer les filtres

How to migrate an Optimization Problem obtained with 'optimproblem' to a Global Optimization Problem that you would get from 'createOptimProblem'

1 vue (au cours des 30 derniers jours)
I was using the Optimization Toolbox and now I want to set up the same problem with the Global Optimization Toolbox using GlobalSearch (new to me).
It seems that I have to use the function 'createOptimProble', which uses different conventions than 'optimproblem'. If I already have a problem defined with 'optimproblem', call it 'prob', I would expect something like the following to work (it won't because e.g. the initial point is missing):
gs = GlobalSearch;
[xg,fg,flg,og] = run(gs,prob)
That is, I would expect 'run' to accept OptimizationProblem objects. Am I missing somethng? If not, is there a simple way to migrate OptimizationProblem objects to be used in 'run'?
ANNEX
Below the structure of my OptimizationProblem (There may be a typo, I redefined everything to make it more understandable and MWE, I cannot provide @MyFUN and the Simulink models, but they are irrelevant).
% Define optimization variable (3 parameters of a Simulink model)
x = optimvar('x', 1, 3, 'LowerBound', zeros(1, 3), 'UpperBound', 10000*ones(1, 3));
% Define optimization expression: sets the 3 parameters in the Simulink model,
% simulates it and returns 3 KPIs
[MyObj, MyConstr1, MyConstr2] = fcn2optimexpr(@MyFUN, x,...
'OutputSize', [1, 1], 'ReuseEvaluation', true);
% Define optimization problem
prob = optimproblem;
prob.Objective = MyObj;
prob.Constraints.MyConstr1 = MyConstr1 <= ValueMyConstr1;
prob.Constraints.MyConstr2 = MyConstr2 <= ValueMyConstr2;
% Define initial point
init_point = [eps, 1000, eps];
x0.x = init_point;
% Define options
options = optimoptions(@fmincon,...
'Display', 'iter-detailed', 'Algorithm', 'interior-point',...
'OptimalityTolerance', 1e-10, 'StepTolerance', 1e-10,...
'FiniteDifferenceStepSize', 1e-6);
% Solve with Optimization Toolbox
[sol, fval, exitflag, output] = solve(prob, x0,...
'options', options, 'solver', 'fmincon')
Thanks!
  1 commentaire
Joan Vazquez
Joan Vazquez le 20 Mar 2020
Narrowing down the question, I think in this case it is better than opening a new thread:
How do I include the nonlinear constraints from an 'optimproblem' in 'createOptimProblem'?
Note that '@MyFun' runs a Simulink model and returns three values: the first one is the objective function, and the second and third are values to be used in constraints. Ideally, I would like something like 'ReuseEvaluation' to avoid running the model again for each constraint...
From the code above, I got to:
init_point = [eps, 1000, eps];
options = optimoptions(@fmincon,...
'Display', 'iter-detailed', 'Algorithm', 'interior-point',...
'OptimalityTolerance', 1e-10, 'StepTolerance', 1e-10,...
'FiniteDifferenceStepSize', 1e-6);
problem = createOptimProblem('fmincon', 'x0', init_point,...
'objective', @MyFun,...
'lb', zeros(1, N) ,'ub', 10000*ones(1, 3),...
'options', options)
% Best practice: validate the solver once
% [x,fval,eflag,output] = fmincon(problem)
gs = GlobalSearch;
[xg, fg, flg, og] = run(gs, problem)

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Surrogate Optimization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by