smooth non-linear optimization

조회 수: 1 (최근 30일)
learner
learner 2015년 8월 1일
댓글: learner 2015년 8월 9일
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:
  1. 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.)
  2. 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

답변 (1개)

Walter Roberson
Walter Roberson 2015년 8월 1일
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.
  댓글 수: 1
learner
learner 2015년 8월 9일
Thanks Walter, it worked but I couldn't understand the logic. What's wrong with function [cost] = optim1( x1, x2 ) as in command window, if I run it, it works fine. Would you please discuss in detail. Also, I've seen functions defined using ^ in math-work documentations. but if we use optimization solver for such functions, why do we need to change ^ to .^ function from some math-work documentation is c(1) = (x(1)^2)/9 + (x(2)^2)/4 - 1
I am trying to learn MATLAB but find it difficult for such small issues. Please help !

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by