LogControl

Controls for functions related to logging

GetStateLogPeriod

public override int GetStateLogPeriod()

Definition

Sets the frequency at which state logs are collected. For example, if set to 5000, logs will be collected once every 5000 states.

Example (Default Logic)

public override int GetStateLogPeriod()
{
    return 5000;
}

WriteSolution

public override void WriteSolution(Solution solution)

Definition

Record the solution obtained by solver.

Example

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

Definition

Sets whether to export the state log to a file.

Return

Type
Description
Default

Boolean

Whether to export state logs.

False

Example

WriteBestSolutionLog

Definition

Write a log for the best solution.

Example

WriteOptimalLog

Definition

Write a log for the optimal solution.

Example

WritePruneLog

Definition

Write a log when the state is pruned.

Example

Since the state may often be pruned, it is recommended not to record logs unless there is a special reason.

Last updated