show
설명
show
를 사용하여 optimization 객체에 대한 정보를 표시합니다.
팁
전체 워크플로는 문제 기반 최적화 워크플로 또는 방정식 풀이를 위한 문제 기반 워크플로 항목을 참조하십시오.
예제
문제 기반 설정 검토하기
단위 원판에 국한된 로젠브록 함수를 최적화하기 위해 문제 생성의 여러 단계를 검토합니다(제약 조건이 있는 비선형 문제 풀기, 문제 기반 참조).
2차원 최적화 변수 x
를 만듭니다. 변수를 표시합니다.
x = optimvar('x',2);
show(x)
[ x(1) ] [ x(2) ]
목적 함수에 대한 표현식을 만듭니다. 표현식을 표시합니다.
obj = log(1 + 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2); show(obj)
log(((1 + (100 .* (x(2) - x(1).^2).^2)) + (1 - x(1)).^2))
제약 조건에 대한 표현식을 만듭니다. 제약 조건을 표시합니다.
cons = x(1)^2 + x(2)^2 <= 1; show(cons)
(x(1).^2 + x(2).^2) <= 1
obj
를 목적 함수로 갖고 cons
를 제약 조건으로 갖는 최적화 문제를 만듭니다. 문제를 표시합니다.
prob = optimproblem("Objective",obj,"Constraints",cons); show(prob)
OptimizationProblem : Solve for: x minimize : log(((1 + (100 .* (x(2) - x(1).^2).^2)) + (1 - x(1)).^2)) subject to : (x(1).^2 + x(2).^2) <= 1
마지막으로 초기점 [0 0]
을 만들고 초기점에서 시작하여 문제를 풉니다.
x0.x = [0 0]; [sol,fval,exitflag] = solve(prob,x0)
Solving problem using fmincon. Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
sol = struct with fields:
x: [2x1 double]
fval = 0.0447
exitflag = OptimalSolution
해에 해당하는 점을 검토합니다.
sol.x
ans = 2×1
0.7864
0.6177
입력 인수
obj
— optimization 객체
OptimizationProblem
객체 | EquationProblem
객체 | OptimizationExpression
객체 | OptimizationVariable
객체 | OptimizationConstraint
객체 | OptimizationEquality
객체 | OptimizationInequality
객체
optimization 객체로, 다음 유형 중 하나로 지정됩니다.
OptimizationProblem
객체 —show(obj)
는 해, 목적 함수, 제약 조건, 변수 범위를 표시합니다.EquationProblem
객체 —show(obj)
는 해, 해의 방정식, 변수 범위를 표시합니다.OptimizationExpression
객체 —show(obj)
는 최적화 표현식을 표시합니다.OptimizationVariable
객체 —show(obj)
는 최적화 변수를 표시합니다. 이 표시는 변수 유형이나 범위를 나타내지 않습니다. 변수 차원과 인덱스 이름(있는 경우)만 표시합니다.OptimizationConstraint
객체 —show(obj)
는 제약 조건 표현식을 표시합니다.OptimizationEquality
객체 —show(obj)
는 등식 표현식을 표시합니다.OptimizationInequality
객체 —show(obj)
는 부등식 표현식을 표시합니다.
버전 내역
R2019b에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)