# LogControl

### GetStateLogPeriod

```csharp
public override int GetStateLogPeriod()
```

#### 정의

State 로그를 기록하는 주기를 설정합니다. 예를 들어, 5000으로 설정되었을 경우 5000개의 State 마다 한번씩 로그를 기록합니다.

#### 예제 (Default Logic)

```csharp
public override int GetStateLogPeriod()
{
    return 5000;
}
```

### WriteSolution

```csharp
public override void WriteSolution(Solution solution)
```

#### 정의

Solution을 기록합니다.

#### 예제

```csharp
public override void WriteSolution(Solution solution)
{
    StringBuilder jobStr = new StringBuilder();
    StringBuilder colorStr = new StringBuilder();
    StringBuilder convStr = new StringBuilder();

    IOrderedEnumerable<KeyValuePair<int, State>> states = solution.States.OrderBy(x => x.Key);

    foreach (KeyValuePair<int, State> item in states)
    {
        CRPState state = item.Value as CRPState;

        if (state.IsInitial)
            continue;

        jobStr.Append(state.LastRetrievedJob.Number);
        colorStr.Append(state.LastRetrievedJob.Color.ColorNumber);
        convStr.Append(state.CurrentConveyor.ConveyorNum);

        if (state.JobCount > 0)
        {
            jobStr.Append("-");
            colorStr.Append("-");
            convStr.Append("-");
        }
    }

    Console.WriteLine(string.Format("Job Sequence: {0}", jobStr.ToString()));
    Console.WriteLine(string.Format("Color Sequence: {0}", colorStr.ToString()));
    Console.WriteLine(string.Format("Conveyor Sequence: {0}", convStr.ToString()));
}
```

### IsExportStateLog

```csharp
 public override bool IsExportStateLog()
```

#### 정의

State 로그를 파일로 Export 할지 여부를 설정합니다.

#### 반환

<table><thead><tr><th width="169.33333333333331">Type</th><th width="348">Description</th><th>Default</th></tr></thead><tbody><tr><td>Boolean</td><td>State 로그 Export 여부입니다.</td><td>False</td></tr></tbody></table>

#### 예제

```csharp
public override bool IsExportStateLog() 
{
    return false;
}
```

### WriteBestSolutionLog

```csharp
public override void WriteBestSolutionLog()
```

#### 정의

현재까지의 Best Solution에 대한 로그를 기록합니다.

#### 예제

```csharp
public override void WriteBestSolutionLog()
{
    SolutionManager solutionManager = SolutionManager.Instance;
    Solution bestSol = solutionManager.BestSolution;

    Console.WriteLine(Constants.LINE);
    Console.WriteLine(string.Format("Objective Value: {0}", bestSol.Value));
    this.WriteSolution(bestSol);
    Console.WriteLine(Constants.LINE);
}
```

### WriteOptimalLog

```csharp
public override void WriteOptimalLog()
```

#### 정의

최적해를 찾고 난 후 로그를 기록합니다.

#### 예제

```csharp
public override void WriteOptimalLog()
{
    SolutionManager solutionManager = SolutionManager.Instance;
    Solution optSol = solutionManager.OptimalSolution;

    Console.WriteLine(Constants.LINE);
    Console.WriteLine(string.Format("Optimal Objective Value: {0}", optSol.Value));
    this.WriteSolution(optSol);
    Console.WriteLine(Constants.LINE);
}
```

### WritePruneLog

```csharp
public override void WritePruneLog(State state)
```

#### 정의

State가 Prune 되었을 때 로그를 기록합니다.

#### 예제

```csharp
public override void WritePruneLog(State state)
{
    Console.WriteLine("Prune => StateIndex:{0}, State:{1}, Stage:{2}, DualBound:{3}, BestValue:{4}, BestPrimalBound:{5}", state.Index, state.ToString(), state.Stage.Index, state.DualBound, state.BestValue, BoundManager.Instance.BestPrimalBound);
}
```

{% hint style="info" %}
State가 Prune 되는 경우가 많을 수 있기 때문에 특별한 사유가 없으면 로그를 기록하지 않는 것을 권장합니다.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://swonh.gitbook.io/sdmp-user-manual-kor/general-module/undefined-1/logcontrol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
