티스토리 뷰

반응형
Non-Linear Minimization with Restrictions

Non-Linear Minimization with Restrictions

제한조건이 있는 비선형 최소화 문제는 다음과 같이 정의 된다.

minxf(x)s. t.c(x)0ceq(x)=0AxbAeqx=beqlbxub

x,b,beq,lb 그리고 ub 는 벡터이고 A 그리고 Aeq 는 행렬이고 c(x),ceq(x) 그리고 F(x) 는 비선형 벡터함수 이다.

[예제] 초기점 x0=[10;10;10], 제한조건 0x1+2x2+2x372 에서 함수 f(x)=x1x2x3 의 최소값을 구하여라. 제한조건을 다시쓰면 아래와 같고 x12x22x30x1+2x2+2x372

행렬로 표현 하면

A=[122122],b=[072]

Axb 형식으로 나타낼 수 있다.

먼저 아래와 같은 함수파일 myfun.m을 만는다.

function f = myfun(x)
f = -x(1)*x(2)*x(3);

다음 실행

A = [-1 -2 -2; 1 2 2];
b = [0 72]';
x0 = [10; 10; 10];
[x,fval] = fmincon(@myfun,x0,A,b)    

결과

x =
    24.0000
    12.0000
    12.0000
fval =
    -3.4560e+03

[예제] 초기점 x0=[1;1], 제한조건 x1x210 그리고 x21+x2=1 에서 함수 f(x)=ex1(4x21+2x22+4x1x2+2x2+1) 의 최소값을 구하여라. 먼저 아래와 같은 목적 함수파일 objfunc.m을 만든다.

function f = objfunc(x)
f = exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1);

다음 제한조건 함수파일 confuneq.m을 만든다.

function [c, ceq] = confuneq(x)
% Nonlinear inequality constraints
c = -x(1)*x(2) - 10;
% Nonlinear equality constraints
ceq = x(1)^2 + x(2) - 1;
% NOTE:
%    If you have more than one inequality/equality then write them as
%      c = [... ; ... ; ...] & ceq = [... ; ... ; ...]
%    If you do not have any inequality/equality then givee them as empty sets
%      c = [] & ceq = []
% NOTE:
%    The direction and form of inequalities must be "g(x) < 0"

다음 실행

x0 = [-1,1]; % Make a starting guess at the solution
options = optimset('LargeScale','off');
[x,fval] = fmincon(@objfun,x0,[],[],[],[],[],[],@confuneq,options)
[c,ceq] = confuneq(x) % Check the constraint values at x
% NOTE:
%    If you have bounds (side constraints) on variables then you go as
%    follows:
%         lb = [0,0];   % Set lower bounds
%         ub = [ ];     % If no upper bounds
%         fmincon(@objfun,x0,[],[],[],[],lb,ub,@confun,options)

결과

x =
    -0.7529    0.4332
fval =
    1.5093
c =
    -9.6739
ceq =
  4.0684e-010       

참고 MathWorks 온라인 도움말 http://kr.mathworks.com/help/optim/ug/fmincon.html

반응형
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함