SDMP User Manual (ENG)
  • Introduction
    • Introduction to SDMP
  • Getting Started
    • Creating SDMP Project
  • Data Handling
    • Loading Input Data
      • Defining Input Data Schema
      • Creating Input Data
      • Loading Input Data
    • Retriving Data
    • Writing Output Data
      • Defining Output Data Schema
      • Adding Data Row
      • Writing to File
  • General Module
    • Overview
    • User Controls
      • StateControl
      • ActionControl
      • StateTransitionControl
      • BoundControl
      • ApproximationControl
      • SolverControl
      • EventControl
      • DataControl
      • LogControl
    • Data Model
      • State
      • StateActionMap
    • Example Problems
      • Car Resequencing Problem
      • Lot Sizing Problem
  • Routing Module
    • Overview
    • User Controls
      • CustomerControl
      • VehicleControl
    • Data Model
    • Example Problems
      • Vehicle Routing Problem
  • Scheduling Module
    • Overview
    • User Controls
    • Data Model
    • Example Problems
Powered by GitBook
On this page
  • GetIntitialState
  • GetKey
  • GetFeasibleSolution
  • CanPruneByOptimality
  1. General Module
  2. User Controls

StateControl

Controls for functions related to state

PreviousUser ControlsNextActionControl

Last updated 1 year ago

GetIntitialState

public override State GetInitialState()

Definition

Define the initial state.

Return

Type
Description
Default

The initial state.

Null

Example

public override State GetInitialState()
{
    CRPData data = DataManager.Instance.Data as CRPData;
    CRPState initState = new CRPState();

    initState.SetStateInfo(data.CRPFactory.Conveyors);

    return initState;
}

GetKey

public override string GetKey(State state)

Definition

Defines the key for the state.

Parameters

Type
Description

The state to define the key.

Return

Type
Description
Default

String

The key of the state.

Example (Default Logic)

public virtual string GetKey(State state)
{
    return state.Index.ToString();
}

GetFeasibleSolution

public override Solution GetFeasibleSolution(State state)

Definition

Define the logic to find a feasible solution based on a given State.

Parameters

Type
Description

The state to find a feasible solution.

Return

Type
Description
Default

Solution

The feasible solution.

Null

Example

public override Solution GetFeasibleSolution(State state)
{           
    CRPState crpState = state as CRPState;
    CRPState copiedState = crpState.Clone();
    copiedState.IsInitial = false;

    List<CRPState> states = new List<CRPState>();
    states.AddRange(copiedState.GetBestStatesBackward().Cast<CRPState>().ToList());

    while (copiedState.JobCount > 0)
    {
        Stage stage = new Stage(copiedState.Stage.Index + 1);
        copiedState.Stage = stage;

        CRPJob lastJob = copiedState.LastRetrievedJob;

        CRPConveyor sameColorConv = copiedState.GetSameColorConveyor(lastJob);

        CRPJob retrievedJob = null;
        if (sameColorConv != null)
        {
            retrievedJob = copiedState.RetrieveJob(sameColorConv.ConveyorNum);
        }
        else 
        {
            retrievedJob = copiedState.RetrieveJob();
        }

        double cost = 0;
        if (lastJob != null && lastJob.Color.ColorNumber != retrievedJob.Color.ColorNumber)
            cost = 1;

        copiedState.BestValue += cost;

        states.Add(copiedState);
        copiedState = copiedState.Clone();
    }

    Solution feasibleSol = new Solution(states);

    return feasibleSol;
}

CanPruneByOptimality

public override bool CanPruneByOptimality(State state, ObjectiveFunctionType objFuncType, double pruneTolerance)

Definition

Determines whether a given state can be pruned without loss of optimality. If the state satisfies the prune conditions, it is excluded.

Parameters

Type
Description

The state to be judged.

ObjectiveFunctionType

The type of objective function in the problem.

Double

The tolerance used for the comparison condition when determining the optimal condition.

Type
Description
Default

Boolean

True: Prunes the state. False: Do not prune the state.

Example (Default Logic)

public override bool CanPruneByOptimality(State state, ObjectiveFunctionType objFuncType, double pruneTolerance)
{
    BoundManager boundManager = BoundManager.Instance;

    double bestPrimalBound = boundManager.BestPrimalBound;
    double dualBound = state.DualBound;
    double bestValue = state.BestValue;

    double rootDualBound = boundManager.RootDualBound;

    if (objFuncType == ObjectiveFunctionType.Minimize)
    {
        if (dualBound < rootDualBound - bestValue)
            dualBound = rootDualBound - bestValue;

        if (bestPrimalBound + pruneTolerance <= bestValue + dualBound)
            return true;
        else
            return false;
    }
    else
    {
        if (dualBound > rootDualBound - bestValue)
            dualBound = rootDualBound - bestValue;

        if (bestPrimalBound >= bestValue + dualBound + pruneTolerance)
            return true;
        else
            return false;
    }
}

⭐
State
State
State
State
Default Logic
Default Logic