> For the complete documentation index, see [llms.txt](https://swonh.gitbook.io/sdmp-user-manual-kor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://swonh.gitbook.io/sdmp-user-manual-kor/general-module/undefined-1/boundcontrol.md).

# BoundControl

### IsUsePrimalBound

```csharp
public override bool IsUsePrimalBound()
```

#### 정의

State에서 Primal Bound를 구하는 로직의 적용 여부를 설정합니다.

#### 반환

<table><thead><tr><th width="115">Type</th><th width="462">Description</th><th>Default</th></tr></thead><tbody><tr><td>Boolean</td><td>True: Primal Bound를 구하는 로직을 적용합니다.<br>False: Primal Bound를 구하는 로직을 적용하지 않습니다.</td><td>True</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override bool IsUsePrimalBound()
{
    return true;
}
```

### IsUseDualBound

```csharp
public override bool IsUseDualBound()
```

#### 정의

State에서 Dual Bound를 구하는 로직의 적용 여부를 설정합니다.

#### 반환

<table><thead><tr><th width="125">Type</th><th width="435">Description</th><th>Default</th></tr></thead><tbody><tr><td>Boolean</td><td>True: Dual Bound를 구하는 로직을 적용합니다.<br>False: Dual Bound를 구하는 로직을 적용하지 않습니다.</td><td>True</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override bool IsUseDualBound()
{
    return true;
}
```

### GetPruneTolerance

<pre class="language-csharp"><code class="lang-csharp"><strong>public override double GetPruneTolerance()
</strong></code></pre>

#### 정의

State를 최적성을 잃지 않고 Prune할 수 있는지 여부를 판단할 때 사용되는 Tolerance 입니다.

#### 반환

<table><thead><tr><th width="186">Type</th><th width="343">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>Prune Tolerance 입니다.</td><td>0.0001</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override double GetPruneTolerance()
{
    return Math.Pow(10, -4);
}
```

### GetPrimalBoundStopStageIndex

```csharp
public override int GetPrimalBoundStopStageIndex()
```

#### 정의

Primal Bound 구하는 로직 적용을 중단하는 Stage의 Index를 설정합니다. 즉, 해당 Stage 부터는 Primal Bound를 구하지 않습니다.

#### 반환

<table><thead><tr><th width="101">Type</th><th width="479">Description</th><th>Default</th></tr></thead><tbody><tr><td>Int</td><td>기준 Stage의 Index 입니다.</td><td>2147483647</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override int GetPrimalBoundStopStageIndex()
{
    return Int32.MaxValue;
}
```

### GetPrimalBoundStopRelativeGap

```csharp
public override double GetPrimalBoundStopRelativeGap()
```

#### 정의

Primal Bound 구하는 로직 적용을 중단하는 기준이 되는 Relative Duality Gap을 설정합니다. 즉, 해당 Relative Duality Gap을 만족하는 Stage 부터는 Primal Bound를 구하지 않습니다.

{% hint style="info" %}
Relative Duality Gap = |Best Dual Bound - Best Primal Bound| / Best Dual Bound
{% endhint %}

#### 반환

<table><thead><tr><th width="110">Type</th><th width="490">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>기준 Relative Duality Gap 값 입니다.</td><td>0</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override double GetPrimalBoundStopRelativeGap() 
{
    return 0;
}
```

### GetDualBoundStopStageIndex

```csharp
public override int GetDualBoundStopStageIndex()
```

#### 정의

Dual Bound 구하는 로직 적용을 중단하는 Stage의 Index를 설정합니다. 즉, 해당 Stage 부터는 Dual Bound를 구하지 않습니다.

#### 반환

<table><thead><tr><th width="99">Type</th><th width="475">Description</th><th>Default</th></tr></thead><tbody><tr><td>Int</td><td>기준 Stage의 Index 입니다.</td><td>2147483647</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override int GetPrimalBoundStopStageIndex()
{
    return Int32.MaxValue;
}
```

### GetDualBoundStopRelativeGap

```csharp
public override double GetDualBoundStopRelativeGap()
```

#### 정의

Dual Bound 구하는 로직 적용을 중단하는 기준이 되는 Relative Duality Gap을 설정합니다. 즉, 해당 Relative Duality Gap을 만족하는 Stage 부터는 Dual Bound를 구하지 않습니다.

#### 반환

<table><thead><tr><th width="129">Type</th><th width="472">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>기준 Relative Duality Gap 값 입니다.</td><td>0</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override double GetDualBoundStopRelativeGap()
{
    return 0;
}
```

### GetInitialPrimalBound

```csharp
 public override double GetInitialPrimalBound(ObjectiveFunctionType objectiveFunctionType)
```

#### 정의

Initial Primal Bound 값을 반환합니다.

#### 매개 변수

| Type                  | Description     |
| --------------------- | --------------- |
| ObjectiveFunctionType | 문제의 목적함수 타입입니다. |

#### 반환

<table><thead><tr><th width="174">Type</th><th width="365">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>Initial Primal Bound 값 입니다.</td><td><a href="#default-logic-7">Default Logic 참조</a></td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override double GetInitialPrimalBound(ObjectiveFunctionType objectiveFunctionType)
{
    double primalBound = 0;

    if (objectiveFunctionType == ObjectiveFunctionType.Maximize)
    {
        primalBound = Double.NegativeInfinity;
    }
    else if (objectiveFunctionType == ObjectiveFunctionType.Minimize)
    {
        primalBound = Double.PositiveInfinity;
    }

    return primalBound;
}
```

### GetInitialDualBound

```csharp
public override double GetInitialDualBound(ObjectiveFunctionType objectiveFunctionType)
```

#### 정의

Initial Dual Bound 값을 반환합니다.

#### 매개 변수

| Type                  | Description     |
| --------------------- | --------------- |
| ObjectiveFunctionType | 문제의 목적함수 타입입니다. |

#### 반환

<table><thead><tr><th width="146">Type</th><th width="398">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>Initial Dual Bound 값 입니다.</td><td><a href="#default-logic-8">Default Logic 참조</a></td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public virtual double GetInitialDualBound(ObjectiveFunctionType objectiveFunctionType)
{
    double dualBound = 0;

    if (objectiveFunctionType == ObjectiveFunctionType.Maximize)
    {
        dualBound = Double.PositiveInfinity;
    }
    else if (objectiveFunctionType == ObjectiveFunctionType.Minimize)
    {
        dualBound = Double.NegativeInfinity;
    }

    return dualBound;
}
```

### UseAbsoluteOptimalityGap

```csharp
public virtual bool UseAbsoluteOptimalityGap()
```

#### 정의

Absolute Duality Gap (Primal Bound와 Dual Bound의 절댓값 차이)를 기준으로 탐색을 종료할지 여부입니다. 즉, Absolute Duality Gap이 설정값 이하일 경우 탐색을 종료합니다.

{% hint style="info" %}
Absolute Duality Gap = |Best Dual Bound - Best Primal Bound|
{% endhint %}

#### 반환

<table><thead><tr><th width="124.33333333333331">Type</th><th width="462">Description</th><th>Default</th></tr></thead><tbody><tr><td>Boolean</td><td>True: 적용<br>False: 미적용 (RelativeOptimalityGap 적용)</td><td>False</td></tr></tbody></table>

{% hint style="warning" %}
반환값이 False일 경우, 탐색 종료 조건으로 Relative Duality Gap이 적용됩니다. ([해당 컨트롤 참조](#getrelativeoptimalitygap))
{% endhint %}

#### 예제 (Default Logic)

```csharp
public virtual bool UseAbsoluteOptimalityGap()
{
    return false;
}
```

### GetRelativeOptimalityGap

```csharp
public virtual double GetRelativeOptimalityGap()
```

#### 정의

탐색을 중단하는 기준이 되는 Relative Duality Gap을 설정합니다. 즉, Relative Duality Gap 값이 설정값 이하일 경우 탐색을 종료합니다.

{% hint style="info" %}
Relative Duality Gap = |Best Dual Bound - Best Primal Bound| / Best Dual Bound
{% endhint %}

#### 반환

<table><thead><tr><th width="128.33333333333331">Type</th><th width="455">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>탐색 종료 조건이 되는 Relative Duality Gap 입니다.</td><td>0</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public virtual double GetRelativeOptimalityGap()
{
    return 0;
}
```

### GetAbsoluteOptimalityGap

```csharp
public virtual double GetAbsoluteOptimalityGap()
```

#### 정의

탐색을 중단하는 기준이 되는 Absolute Duality Gap을 설정합니다. 즉, Absolute Duality Gap 값이 설정값 이하일 경우 탐색을 종료합니다.

#### 반환

<table><thead><tr><th width="132.33333333333331">Type</th><th width="430">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>탐색 종료 조건이 되는 Absolute Duality Gap 입니다.</td><td>0</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public virtual double GetAbsoluteOptimalityGap()
{
    return 0;
}
```

### GetDualBound

```csharp
public virtual double GetDualBound(State state)
```

#### 정의

주어진 State의 Dual Bound를 반환합니다.

#### 매개 변수

<table><thead><tr><th width="157">Type</th><th>Description</th></tr></thead><tbody><tr><td>State</td><td>Dual Bound를 구할 대상 State 입니다.</td></tr></tbody></table>

#### 반환

<table><thead><tr><th width="139">Type</th><th width="428">Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>State의 Dual Bound 입니다.</td><td>0</td></tr></tbody></table>

#### 예제

```csharp
public override double GetDualBound(State state)
{
    double bound = 0;
    CRPState crpState = state as CRPState;

    bound = crpState.GetTotalColorCount() - 1;

    return bound;
}
```

### GetPrimalBound

```csharp
public override double GetPrimalBound(Solution solution)
```

#### 정의

주어진 Feasible solution에 해당하는 Primal Bound를 반환합니다.

#### 매개 변수

<table><thead><tr><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td>Solution</td><td>Primal Bound를 구할 때 기준이 되는 Solution 입니다.</td></tr></tbody></table>

#### 반환

<table><thead><tr><th width="164">Type</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td>Double</td><td>Primal Bound 값 입니다.</td><td>Default Logic 참</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override double GetPrimalBound(Solution solution)
{
    return solution.Value;
}
```

### GetPrimalSolutionUpdatePeriod

```csharp
public override int GetPrimalSolutionUpdatePeriod()
```

#### 정의

State에서 Primal Solution을 구하는 로직을 적용할 State 개수 주기를 반환합니다. 예를 들어, 주기를 1000으로 설정하였을 경우, 1000개의 State마다 한번씩 Primal Solution을 구하는 로직이 적용됩니다.

#### 반환

<table><thead><tr><th width="112">Type</th><th width="449">Description</th><th>Default</th></tr></thead><tbody><tr><td>Int</td><td>Primal Solution을 구하는 로직을 적용할 주기 입니다.</td><td>1000</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public override int GetPrimalSolutionUpdatePeriod()
{
    return 1000;
}
```

### GetDualBoundUpdatePeriod

```csharp
public override int GetDualBoundUpdatePeriod()
```

#### 정의

State에서 Dual Bound를 구하는 로직을 적용할 State 개수 주기를 반환합니다. 예를 들어, 주기를 1000으로 설정하였을 경우, 1000개의 State마다 한번씩 Dual Bound를 구하는 로직이 적용됩니다.

#### 반환

<table><thead><tr><th width="126">Type</th><th width="434">Description</th><th>Default</th></tr></thead><tbody><tr><td>Int</td><td>Primal Solution을 구하는 로직을 적용할 주기 입니다.</td><td>1</td></tr></tbody></table>

#### 예제 (Default Logic)

```csharp
public virtual int GetDualBoundUpdatePeriod()
{
    return 1;
}
```
