How to transmit variables in problem structure

조회 수: 1 (최근 30일)
John Miller
John Miller 2020년 9월 14일
편집: Stephen23 2020년 9월 14일
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

채택된 답변

Stephen23
Stephen23 2020년 9월 14일
편집: Stephen23 2020년 9월 14일
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), ..)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by