티스토리 뷰

반응형
Non-Linear Minimization with Restrictions

Non-Linear Minimization with Restrictions

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

\[\begin{aligned} & \underset{x}{\text{min}} & & f(x) \\ & \text{s. t.} & & c(x) \leq 0 \\ & & & ceq(x) = 0\\ & & & A \cdot x \leq b\\ & & & Aeq \cdot x = beq \\ & & & lb \leq x \leq ub \\ \end{aligned}\]

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

[예제] 초기점 \( x_0 = [10; 10; 10]\), 제한조건 \( 0 \leq x_1 + 2 x_2 + 2x_3 \leq 72 \) 에서 함수 \( f(x)=-x_1 x_2 x_3 \) 의 최소값을 구하여라. 제한조건을 다시쓰면 아래와 같고 \(\begin{aligned} - x_1 - 2 x_2 - 2 x_3 \leq 0 \\ x_1 + 2 x_2 + 2 x_3 \leq 72 \end{aligned} \)

행렬로 표현 하면

\[ A = \left[ \begin{matrix} -1& -2 & -2 \\ 1& 2 & 2 \\ \end{matrix} \right], b=\left[\begin{matrix} 0 \\ 72 \end{matrix}\right]\]

\( A x \leq b \) 형식으로 나타낼 수 있다.

먼저 아래와 같은 함수파일 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

[예제] 초기점 \( x_0 = [-1; 1]\), 제한조건 \( -x_1 x_2 \leq 10 \) 그리고 \( x_1^2 + x_2 = 1 \) 에서 함수 \( f(x)=e^{x_1}(4x_1^2+2x_2^2+4x_1x_2+2x_2+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
«   2024/05   »
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 31
글 보관함