smooth non-linear optimization
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to minimize cost function (using Matlab optimization toolbox) with constraints x1 < x2 and 0 < x1, 0 < x2. I've the following issues:
- When I try using fmincon; it says Error running optimization. Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead. I've tried the same and got the error "Not enough input arguments" (I've given start point [0 0] in both cases.)
- This problem is not convex, so I need to use Global solvers to find global optimum. I've Global optimization tool box installed (I've checked using 'ver' command) but I don't see Global optimization tool box in apps. Please let me know how to start it.
My function defined in m-file is as below:
function [cost] = optim1( x1, x2 )
% Input arguments
k1=150;
k2=200;
c1=0.1;
c2=0.75;
c3=0.2;
c4=100;
alpha=0.01;
beta=2;
a=80;
b=0.3;
lamda=0.2;
x=0.5;
y=0.9;
%time=[x1 x2];
% To break coeff functions in smaller parts
A =(lamda*x-lamda^2/2)* x1^2;
B = (alpha*x1^(beta+2))/(beta+1);
C = (- beta * lamda^(beta+2))/(beta+2)+(x*(lamda^(beta+1))- lamda* (x^(beta+1)));
D = (x - lamda)^2 * (x1^2)/2;
E = (alpha*(x1^(beta+2)))/(beta+1);
F = C + (beta * x^(beta+2))/(beta+2);
G = ((1 - x)^2 * (x1^2))/2;
H = beta/(beta+2)-(beta*(x^(beta+2)))/(beta+2)- x + (x^(beta+1));
I = ((2 - 3 * x)*((x1)^3)/3);
J = alpha*((x1)^(beta+3));
K = (2*beta)/((beta+1)*(beta+3)) - ((2*x)/(beta+2)) - x + ((x^(beta+1))/(beta+1));
L = (((y-1)*(x2^2))/2) - x2*x1;
M = (a*((y*x2 - x1)^2))/2;
N = ((x1)^3)+2*(x2^3) - 3*((x2)^2)*x1;
% coeff functions
coeff1 = (k1-a)*(A + (B*C)) + (k2-a)*(D - E*F) + a*(G + B*H) + (b/2)*(I + J*K);
coeff2 = (k1-a)*(1-y)*L - M - (b/6)*N;
coeff3 = (k1*lamda*x1 + (k2*(x-lamda)*x1) - a*x1 - (b*((x1)^2))/2)*c3;
% To define objective function to minimize
cost = ((c1*coeff1) + (c2*coeff2) + (c3*coeff3) + c4)/x2;
end
0 commentaires
Réponses (1)
Walter Roberson
le 1 Août 2015
function [cost] = optim1( x )
x1 = x(:,1);
x2 = x(:,2);
and convert pretty much all of your ^ to .^
Note: you might need x(1,:) and x(2,:) instead -- the shape passed in is not always well documented.
Voir également
Catégories
En savoir plus sur Get Started with Optimization Toolbox 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!