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.