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)