OptimizationVariable
최적화를 위한 변수
설명
OptimizationVariable 객체에는 최적화 표현식을 위한 변수가 포함됩니다. 목적 함수, 제약 조건 또는 방정식을 나타내는 표현식을 사용하십시오. 변수는 본질적으로 기호 변수이며, 모든 크기의 배열일 수 있습니다.
팁
전체 워크플로는 문제 기반 최적화 워크플로 또는 방정식 풀이를 위한 문제 기반 워크플로 항목을 참조하십시오.
생성
optimvar을 사용하여 OptimizationVariable 객체를 만듭니다.
속성
배열 전체에 적용되는 속성
변수 유형으로, 'continuous', 'integer', 'semi-continuous' 또는 'semi-integer'로 지정됩니다.
'continuous'— 실수 값.'integer'— 정수 값.'semi-continuous'— 0이거나 하한과 상한 사이의 실수 값으로, 순양수(Strictly Positive)여야 하며1e5를 초과할 수 없습니다. 이 유형은 혼합 정수 선형 계획법(intlinprog)에만 적용됩니다.'semi-integer'— 0이거나 하한과 상한 사이의 정수 값으로, 순양수(Strictly Positive)여야 하며1e5를 초과할 수 없습니다. 이 유형은 혼합 정수 선형 계획법(intlinprog)에만 적용됩니다.
Type은 전체 변수 배열에 적용됩니다. 여러 변수 유형을 포함하려면 변수를 여러 개 만드십시오.
팁
이진 변수를 지정하려면 'integer' 유형을 사용하고 LowerBound = 0 및 UpperBound = 1을 지정하십시오.
데이터형: char | string
인덱스 이름으로, string형 또는 문자형 벡터로 구성된 셀형 배열로 지정됩니다. 인덱스 이름 사용에 관한 자세한 내용은 Named Index for Optimization Variables 항목을 참조하십시오.
데이터형: cell
요소별 속성
하한으로, OptimizationVariable 객체와 동일한 차원의 실수형 스칼라 또는 실수형 배열로 지정됩니다. 스칼라 값은 변수의 모든 요소에 적용됩니다.
LowerBound 속성은 항상 배열로 표시됩니다. 그러나 속성을 모든 요소에 적용되는 스칼라로 설정할 수 있습니다. 예를 들면 다음과 같습니다.
var.LowerBound = 0
데이터형: double
상한으로, 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 =
3×1 OptimizationVariable array with properties:
Array-wide properties:
Name: 'x'
Type: 'continuous'
IndexNames: {{} {}}
Elementwise properties:
LowerBound: [3×1 double]
UpperBound: [3×1 double]
See variables with show.
See bounds with showbounds.
string형 "brass", "stainless", "galvanized"로 인덱싱된 정수 최적화 변수 벡터 bolts를 만듭니다. bolts의 인덱스를 사용하여 최적화 표현식을 만들고, 문자형 배열을 사용하거나 다른 방향으로 bolts 생성을 시험해 봅니다.
행 방향으로 string형을 사용하여 bolts를 만듭니다.
bnames = ["brass","stainless","galvanized"]; bolts = optimvar("bolts",bnames,Type="integer")
bolts =
1×3 OptimizationVariable array with properties:
Array-wide properties:
Name: 'bolts'
Type: 'integer'
IndexNames: {{} {1×3 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 =
1×3 OptimizationVariable array with properties:
Array-wide properties:
Name: 'bolts'
Type: 'integer'
IndexNames: {{} {1×3 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 =
3×1 OptimizationVariable array with properties:
Array-wide properties:
Name: 'bolts'
Type: 'integer'
IndexNames: {{1×3 cell} {}}
Elementwise properties:
LowerBound: [3×1 double]
UpperBound: [3×1 double]
See variables with show.
See bounds with showbounds.
xarray라는 최적화 변수로 구성된 3×4×2 배열을 만듭니다.
xarray = optimvar("xarray",3,4,2)xarray =
3×4×2 OptimizationVariable array with properties:
Array-wide properties:
Name: 'xarray'
Type: 'continuous'
IndexNames: {{} {} {}}
Elementwise properties:
LowerBound: [3×4×2 double]
UpperBound: [3×4×2 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 =
3×4 OptimizationVariable array with properties:
Array-wide properties:
Name: 'bolts'
Type: 'continuous'
IndexNames: {{1×3 cell} {}}
Elementwise properties:
LowerBound: [3×4 double]
UpperBound: [3×4 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 =
3×3×3 OptimizationVariable array with properties:
Array-wide properties:
Name: 'x'
Type: 'integer'
IndexNames: {{} {} {}}
Elementwise properties:
LowerBound: [3×3×3 double]
UpperBound: [3×3×3 double]
See variables with show.
See bounds with showbounds.
하한이 , 상한이 인 x라는 반연속 최적화 변수를 만듭니다.
x = optimvar("x",Type="semi-continuous",... LowerBound=pi/2,UpperBound=2*pi)
x =
OptimizationVariable with properties:
Name: 'x'
Type: 'semi-continuous'
IndexNames: {{} {}}
LowerBound: 1.5708
UpperBound: 6.2832
See variables with show.
See bounds with showbounds.
하한이 [10,20,30], 상한이 [20,40,60]인 y라는 반정수(semi-integer) 3차원 변수를 만듭니다.
y = optimvar("y",3,Type="semi-integer",... LowerBound=[10,20,30],UpperBound=[20,40,60])
y =
3×1 OptimizationVariable array with properties:
Array-wide properties:
Name: 'y'
Type: 'semi-integer'
IndexNames: {{} {}}
Elementwise properties:
LowerBound: [3×1 double]
UpperBound: [3×1 double]
See variables with show.
See bounds with showbounds.
반연속 변수와 반정수(semi-integer) 변수는 1e5를 초과하지 않는 순양수(Strictly Positive) 범위를 가져야 합니다.
세부 정보
최적화 변수에 지원되는 연산 목록은 Supported Operations for Optimization Variables and Expressions 항목을 참조하십시오.
최적화 변수 참조는 다른 최적화 변수의 일부인 최적화 변수입니다. 참조 변수는 원래 변수를 가리키는데 이는 원래 변수의 별칭이라는 의미입니다. 참조 변수는 독립적으로 존재하지 않습니다.
예를 들어, x가 요소를 3개 가진 최적화 변수라고 가정하겠습니다.
x = optimvar("x",3,1);y를 x의 마지막 두 개 요소로 받습니다.
y = x(2:3);
이때 y(1)은 x(2)의 별칭이고 y(2)는 x(3)의 별칭입니다. 최적화 표현식에 y를 사용하는 경우 표현식에는 y가 아니라 x가 포함됩니다. 예를 들면 다음과 같습니다.
expr = [1,2]*y
expr = OptimizationExpression x(2) + 2*x(3)
그리고 y를 수정하면 x가 수정됩니다. 예를 들면 다음과 같습니다.
y.LowerBound = 2; showbounds(x)
2 <= x(2, 1) 2 <= x(3, 1)
혼합 정수 선형 계획법 문제의 경우 변수에 대해 Type="semi-continuous" 또는 Type="semi-integer"를 지정할 수 있습니다. 이러한 변수는 1e5를 초과하지 않는 순양수(Strictly Positive) 범위를 가져야 합니다.
반연속 변수와 반정수(semi-integer) 변수는 값 0을 받거나 하한에서 상한 사이의 임의의 값을 받을 수 있습니다. 반정수(semi-integer) 변수는 범위 내의 정수 값만 받을 수 있는 반면, 반연속 변수는 범위 내의 모든 실수 값을 받을 수 있습니다.
팁
OptimizationVariable객체는 핸들 복사 동작을 지닙니다. 핸들 객체 동작 항목과 핸들 클래스와 값 클래스 비교 항목을 참조하십시오. 핸들 복사 동작은OptimizationVariable의 복사본이 원본을 가리킬 뿐 독립적으로 존재하지 않는다는 의미입니다. 예를 들어 변수x를 만들어y에 복사한 다음,y의 속성을 설정합니다.x가 새 속성값을 갖는 것을 알 수 있습니다.x = optimvar("x",LowerBound=1); y = x; y.LowerBound = 0; showbounds(x)0 <= x
버전 내역
R2017b에 개발됨혼합 정수 선형 계획법 문제의 경우, 변수는 유형 'semi-continuous' 또는 'semi-integer'를 가질 수 있습니다. 반연속 변수 및 반정수(semi-integer) 변수 항목을 참조하십시오.
"like" 구문을 사용하여 최적화 변수를 만들 수 있습니다. 이 기능을 사용하면 Use "like" Syntax to Initialize the Array에 나와 있는 것처럼 최적화 표현식의 초기화를 단순화할 수 있습니다.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)