티스토리 뷰
반응형
Non-Linear Minimization with Restrictions
제한조건이 있는 비선형 최소화 문제는 다음과 같이 정의 된다.
minxf(x)s. t.c(x)≤0ceq(x)=0A⋅x≤bAeq⋅x=beqlb≤x≤ub
x,b,beq,lb 그리고 ub 는 벡터이고 A 그리고 Aeq 는 행렬이고 c(x),ceq(x) 그리고 F(x) 는 비선형 벡터함수 이다.
[예제] 초기점 x0=[10;10;10], 제한조건 0≤x1+2x2+2x3≤72 에서 함수 f(x)=−x1x2x3 의 최소값을 구하여라. 제한조건을 다시쓰면 아래와 같고 −x1−2x2−2x3≤0x1+2x2+2x3≤72
행렬로 표현 하면
A=[−1−2−2122],b=[072]
Ax≤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
[예제] 초기점 x0=[−1;1], 제한조건 −x1x2≤10 그리고 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
반응형
'Old > temp' 카테고리의 다른 글
학생을 위한 Nonlinear optimization 저장소(repository in julia) (0) | 2016.06.17 |
---|---|
julia Optim 패키지를 이용하여 Himmelblau's function의 극값을 찾는 방법 (0) | 2016.06.16 |
피보나치 수열의 일반항, fibonacci numbers (0) | 2016.04.25 |
NonLinear Scalar Optimization With Boundary Conditions for MATLAB (0) | 2015.07.08 |
유효숫자 significant digit (0) | 2015.07.08 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 수학
- IOS
- ipad
- 대전
- unconstrained
- iPhone
- 프로야구
- 기아 야구
- 2016프로야구
- latex
- 아이폰
- 스팸
- matlab
- 태풍
- 기아타이거즈
- 프로축구
- KIA
- 농촌 진흥청
- 국토교통부
- OS X
- 새누리당
- 박정수
- kia타이거즈
- 2016 프로야구
- 바이리뷰
- optimization
- 아이패드
- 양현종
- 임준혁
- 기상청
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함