OptimizationVariable
최적화를 위한 변수
설명
OptimizationVariable
객체에는 최적화 표현식을 위한 변수가 포함됩니다. 목적 함수, 제약 조건 또는 방정식을 나타내는 표현식을 사용하십시오. 변수는 본질적으로 기호 변수이며, 모든 크기의 배열일 수 있습니다.
팁
전체 워크플로는 문제 기반 최적화 워크플로 또는 방정식 풀이를 위한 문제 기반 워크플로 항목을 참조하십시오.
생성
optimvar
을 사용하여 OptimizationVariable
객체를 만듭니다.
속성
배열 전체에 적용되는 속성
Type
— 변수 유형
'continuous'
(디폴트 값) | 'integer'
변수 유형으로, 'continuous'
또는 'integer'
로 지정됩니다.
'continuous'
– 실수 값'integer'
– 정수 값
변수 유형은 배열에 포함된 모든 변수에 적용됩니다. 여러 변수 유형을 포함하려면 변수를 여러 개 만드십시오.
팁
이진 변수를 지정하려면 'integer'
유형을 사용하고 LowerBound
= 0
및 UpperBound
= 1
을 지정하십시오.
데이터형: char
| string
IndexNames
— 인덱스 이름
''
(디폴트 값) | string형으로 구성된 셀형 배열 | 문자형 벡터로 구성된 셀형 배열
인덱스 이름으로, string형 또는 문자형 벡터로 구성된 셀형 배열로 지정됩니다. 인덱스 이름 사용에 관한 자세한 내용은 Named Index for Optimization Variables 항목을 참조하십시오.
데이터형: cell
요소별 속성
LowerBound
— 하한
-Inf
(디폴트 값) | 실수형 스칼라 | 실수형 배열
하한으로, OptimizationVariable
객체와 동일한 차원의 실수형 스칼라 또는 실수형 배열로 지정됩니다. 스칼라 값은 변수의 모든 요소에 적용됩니다.
LowerBound
속성은 항상 배열로 표시됩니다. 그러나 속성을 모든 요소에 적용되는 스칼라로 설정할 수 있습니다. 예를 들면 다음과 같습니다.
var.LowerBound = 0
데이터형: double
UpperBound
— 상한
Inf
(디폴트 값) | 실수형 스칼라 | 실수형 배열
상한으로, OptimizationVariable
객체와 동일한 차원의 실수형 스칼라 또는 실수형 배열로 지정됩니다. 스칼라 값은 변수의 모든 요소에 적용됩니다.
UpperBound
속성은 항상 배열로 표시됩니다. 그러나 속성을 모든 요소에 적용되는 스칼라로 설정할 수 있습니다. 예를 들면 다음과 같습니다.
var.UpperBound = 1
데이터형: double
객체 함수
show | optimization 객체에 대한 정보 표시 |
showbounds | 변수 범위 표시 |
write | Save optimization object description |
writebounds | Save description of variable bounds |
예제
스칼라 최적화 변수 만들기
스칼라 최적화 변수 dollars
를 만듭니다.
dollars = optimvar('dollars')
dollars = OptimizationVariable with properties: Name: 'dollars' Type: 'continuous' IndexNames: {{} {}} LowerBound: -Inf UpperBound: Inf See variables with show. See bounds with showbounds.
최적화 변수 벡터 만들기
3×1 최적화 변수 벡터 x
를 만듭니다.
x = optimvar('x',3)
x = 3x1 OptimizationVariable array with properties: Array-wide properties: Name: 'x' Type: 'continuous' IndexNames: {{} {}} Elementwise properties: LowerBound: [3x1 double] UpperBound: [3x1 double] See variables with show. See bounds with showbounds.
string형으로 인덱싱된 최적화 변수 만들기
string형 "brass"
, "stainless"
, "galvanized"
로 인덱싱된 정수 최적화 변수 벡터 bolts
를 만듭니다. bolts
의 인덱스를 사용하여 최적화 표현식을 만들고, 문자형 배열을 사용하거나 다른 방향으로 bolts
생성을 시험해 봅니다.
행 방향으로 string형을 사용하여 bolts
를 만듭니다.
bnames = ["brass","stainless","galvanized"]; bolts = optimvar('bolts',bnames,'Type','integer')
bolts = 1x3 OptimizationVariable array with properties: Array-wide properties: Name: 'bolts' Type: 'integer' IndexNames: {{} {1x3 cell}} Elementwise properties: LowerBound: [-Inf -Inf -Inf] UpperBound: [Inf Inf Inf] See variables with show. See bounds with showbounds.
string형 인덱스를 사용하여 최적화 표현식을 만듭니다.
y = bolts("brass") + 2*bolts("stainless") + 4*bolts("galvanized")
y = Linear OptimizationExpression bolts('brass') + 2*bolts('stainless') + 4*bolts('galvanized')
string형 대신에 문자형 벡터로 구성된 셀형 배열을 사용하여 이전과 동일한 인덱스를 갖는 변수를 얻습니다.
bnames = {'brass','stainless','galvanized'}; bolts = optimvar('bolts',bnames,'Type','integer')
bolts = 1x3 OptimizationVariable array with properties: Array-wide properties: Name: 'bolts' Type: 'integer' IndexNames: {{} {1x3 cell}} Elementwise properties: LowerBound: [-Inf -Inf -Inf] UpperBound: [Inf Inf Inf] See variables with show. See bounds with showbounds.
1×3이 아닌 3×1의 열 방향 버전 bnames
를 사용하고 bolts
가 열 방향을 갖는지도 살펴봅니다.
bnames = ["brass";"stainless";"galvanized"]; bolts = optimvar('bolts',bnames,'Type','integer')
bolts = 3x1 OptimizationVariable array with properties: Array-wide properties: Name: 'bolts' Type: 'integer' IndexNames: {{1x3 cell} {}} Elementwise properties: LowerBound: [3x1 double] UpperBound: [3x1 double] See variables with show. See bounds with showbounds.
다차원 최적화 변수 만들기
xarray
라는 최적화 변수로 구성된 3×4×2 배열을 만듭니다.
xarray = optimvar('xarray',3,4,2)
xarray = 3x4x2 OptimizationVariable array with properties: Array-wide properties: Name: 'xarray' Type: 'continuous' IndexNames: {{} {} {}} Elementwise properties: LowerBound: [3x4x2 double] UpperBound: [3x4x2 double] See variables with show. See bounds with showbounds.
이름과 숫자형 인덱스의 혼합으로 인덱싱된 다차원 변수를 만들 수도 있습니다. 예를 들어 최적화 변수로 구성된 3×4 배열을 만듭니다. 여기서 첫 번째 차원은 string형 'brass'
, 'stainless'
, 'galvanized'
로 인덱싱되고, 두 번째 차원은 수치적으로 인덱싱됩니다.
bnames = ["brass","stainless","galvanized"]; bolts = optimvar('bolts',bnames,4)
bolts = 3x4 OptimizationVariable array with properties: Array-wide properties: Name: 'bolts' Type: 'continuous' IndexNames: {{1x3 cell} {}} Elementwise properties: LowerBound: [3x4 double] UpperBound: [3x4 double] See variables with show. See bounds with showbounds.
이진 최적화 변수 만들기
이진 변수를 나타내며 크기가 3×3×3인 최적화 변수 x
를 만듭니다.
x = optimvar('x',3,3,3,'Type','integer','LowerBound',0,'UpperBound',1)
x = 3x3x3 OptimizationVariable array with properties: Array-wide properties: Name: 'x' Type: 'integer' IndexNames: {{} {} {}} Elementwise properties: LowerBound: [3x3x3 double] UpperBound: [3x3x3 double] See variables with show. See bounds with showbounds.
세부 정보
산술 연산
최적화 변수에 지원되는 연산 목록은 Supported Operations for Optimization Variables and Expressions 항목을 참조하십시오.
팁
OptimizationVariable
객체는 핸들 복사 동작을 지닙니다. 핸들 객체 동작 항목과 핸들 클래스와 값 클래스 비교 항목을 참조하십시오. 핸들 복사 동작은OptimizationVariable
의 복사본이 원본을 가리킬 뿐 독립적으로 존재하지 않는다는 의미입니다. 예를 들어 변수x
를 만들어y
에 복사한 다음,y
의 속성을 설정합니다.x
가 새 속성값을 갖는 것을 알 수 있습니다.x = optimvar('x','LowerBound',1); y = x; y.LowerBound = 0; showbounds(x)
0 <= x
버전 내역
R2017b에 개발됨
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)