Main Content

OptimizationVariable

최적화를 위한 변수

설명

OptimizationVariable 객체에는 최적화 표현식을 위한 변수가 포함됩니다. 목적 함수, 제약 조건 또는 방정식을 나타내는 표현식을 사용하십시오. 변수는 본질적으로 기호 변수이며, 모든 크기의 배열일 수 있습니다.

전체 워크플로는 문제 기반 최적화 워크플로 또는 방정식 풀이를 위한 문제 기반 워크플로 항목을 참조하십시오.

생성

optimvar을 사용하여 OptimizationVariable 객체를 만듭니다.

속성

모두 확장

배열 전체에 적용되는 속성

읽기 전용 속성입니다.

변수 이름으로, string형 또는 문자형 벡터로 지정됩니다.

show 또는 write에서와 같이 Name은 표시할 변수 레이블을 지정합니다. Name은 또한 solve가 반환하는 해 구조체의 필드 이름도 지정합니다.

혼동을 피하려면 name을 MATLAB® 변수 이름이 되도록 설정하십시오. 예를 들면 다음과 같습니다.

metal = optimvar('metal')

데이터형: char | string

변수 유형으로, 'continuous' 또는 'integer'로 지정됩니다.

  • 'continuous' – 실수 값

  • 'integer' – 정수 값

변수 유형은 배열에 포함된 모든 변수에 적용됩니다. 여러 변수 유형을 포함하려면 변수를 여러 개 만드십시오.

이진 변수를 지정하려면 'integer' 유형을 사용하고 LowerBound = 0UpperBound = 1을 지정하십시오.

데이터형: char | string

인덱스 이름으로, string형 또는 문자형 벡터로 구성된 셀형 배열로 지정됩니다. 인덱스 이름 사용에 관한 자세한 내용은 Named Index for Optimization Variables 항목을 참조하십시오.

데이터형: cell

요소별 속성

하한으로, OptimizationVariable 객체와 동일한 차원의 실수형 스칼라 또는 실수형 배열로 지정됩니다. 스칼라 값은 변수의 모든 요소에 적용됩니다.

LowerBound 속성은 항상 배열로 표시됩니다. 그러나 속성을 모든 요소에 적용되는 스칼라로 설정할 수 있습니다. 예를 들면 다음과 같습니다.

var.LowerBound = 0

데이터형: double

상한으로, OptimizationVariable 객체와 동일한 차원의 실수형 스칼라 또는 실수형 배열로 지정됩니다. 스칼라 값은 변수의 모든 요소에 적용됩니다.

UpperBound 속성은 항상 배열로 표시됩니다. 그러나 속성을 모든 요소에 적용되는 스칼라로 설정할 수 있습니다. 예를 들면 다음과 같습니다.

var.UpperBound = 1

데이터형: double

객체 함수

showoptimization 객체에 대한 정보 표시
showbounds변수 범위 표시
writeSave optimization object description
writeboundsSave 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형 "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.

세부 정보

모두 확장

  • OptimizationVariable 객체는 핸들 복사 동작을 지닙니다. 핸들 객체 동작 항목과 핸들 클래스와 값 클래스 비교 항목을 참조하십시오. 핸들 복사 동작은 OptimizationVariable의 복사본이 원본을 가리킬 뿐 독립적으로 존재하지 않는다는 의미입니다. 예를 들어 변수 x를 만들어 y에 복사한 다음, y의 속성을 설정합니다. x가 새 속성값을 갖는 것을 알 수 있습니다.

    x = optimvar('x','LowerBound',1);
    y = x;
    y.LowerBound = 0;
    showbounds(x)
        0 <= x

버전 내역

R2017b에 개발됨