How to transmit variables in problem structure

3 vues (au cours des 30 derniers jours)
John Miller
John Miller le 14 Sep 2020
Modifié(e) : Stephen23 le 14 Sep 2020
I am trying to set up a problem structure for fmincon
...
gs = GlobalSearch;
problem = createOptimProblem('fmincon','objective', @objective, 'x0', x0, ...
'Aineq', A, 'bineq', B, 'Aeq', Aeq, 'beq', Beq, 'lb', lb, ...
'ub', ub, 'nonlcon', nonlincon, 'options', optoptim);
run(gs,problem)
However the function 'objective' needs some values inserted
function [f,g] = objective(x0,t1,t2,t3,t4,t5)
...
How can I transmit the values t1,...,t5 ? They are vectors I define earlier in the code

Réponse acceptée

Stephen23
Stephen23 le 14 Sep 2020
Modifié(e) : Stephen23 le 14 Sep 2020
You need to parameterize the function:
For example using an anonymous function:
t1 = ..;
t2 = ..;
t3 = ..;
t4 = ..;
t5 = ..;
problem = createOptimProblem(.., 'objective', @(x)objective(x,t1,t2,t3,t4,t5), ..)

Plus de réponses (0)

Catégories

En savoir plus sur Global or Multiple Starting Point Search 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