Global optimization - data type error
Afficher commentaires plus anciens
Hi,
I am trying to minimize the objective below using global optimization. The error I received is: "Error using fmincon. FMINCON requires all values returned by functions to be of data type double. Caused by: Failure in initial call to fmincon with user-supplied problem structure." I don't know how to fix this error. Any idea will be appreciated. Thanks in advance!
syms Cm Cc Cv Co
Cf = 1 - Cc - Cm - Cv - Co;
G = Cm*log(Cm) + Cc*log(Cc) + Cv*log(Cv) + Co*log(Co);
% Calculate the derivative of G w.r.t. the four variables
sym_mu_c = diff(G, Cc);
sym_mu_m = diff(G, Cm);
sym_mu_v = diff(G, Cv);
sym_mu_o = diff(G, Co);
% This function is to be minimized
sym_dis = vpa((sym_mu_c.^2 + sym_mu_m.^2 + sym_mu_v.^2 + sym_mu_o.^2).^0.5);
% Convert syms function to matlab function
mu_dis = matlabFunction(sym_dis);
% Bounds of the four variables
lowb = [0;0;0;0];
uppb = [1;1;1;1];
% Objective
obj = @(x)mu_dis;
% Define problem
gs = GlobalSearch;
opts = optimoptions(@fmincon, 'Algorithm', 'interior-point', 'MaxFunctionEvaluations', 1e6, 'MaxIterations', 1e6);
init = [0.204; 0.075; 1e-2; 1e-2];
prob = createOptimProblem('fmincon', 'x0', init, 'objective', obj, 'lb', lowb, 'ub', uppb, 'options', opts);
[x, fval] = run(gs, prob)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Surrogate Optimization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!