/// <summary> /// Instantiates a scoring function from the given config. /// </summary> /// <param name="scorerConfig">The config.</param> /// <param name="stationAssignment">Indicates whether the order shall be assigned to the station directly.</param> /// <returns>The scoring function.</returns> private Func <double> GenerateScorer(QueueOrderSelectionRuleConfig scorerConfig, bool stationAssignment) { switch (scorerConfig.Type()) { case QueueOrderSelectionRuleType.Random: { QueueOrderSelectionRandom tempcfg = scorerConfig as QueueOrderSelectionRandom; return(() => { return Score(tempcfg, stationAssignment); }); } case QueueOrderSelectionRuleType.FCFS: { QueueOrderSelectionFCFS tempcfg = scorerConfig as QueueOrderSelectionFCFS; return(() => { return Score(tempcfg, stationAssignment); }); } case QueueOrderSelectionRuleType.EarliestDeadline: { QueueOrderSelectionEarliestDeadline tempcfg = scorerConfig as QueueOrderSelectionEarliestDeadline; return(() => { return Score(tempcfg, stationAssignment); }); } case QueueOrderSelectionRuleType.VacantDeadline: { QueueOrderSelectionDeadlineVacant tempcfg = scorerConfig as QueueOrderSelectionDeadlineVacant; return(() => { return Score(tempcfg, stationAssignment); }); } case QueueOrderSelectionRuleType.InboundMatches: { QueueOrderSelectionInboundMatches tempcfg = scorerConfig as QueueOrderSelectionInboundMatches; return(() => { return Score(tempcfg, stationAssignment); }); } case QueueOrderSelectionRuleType.Completable: { QueueOrderSelectionCompleteable tempcfg = scorerConfig as QueueOrderSelectionCompleteable; return(() => { return Score(tempcfg, stationAssignment); }); } case QueueOrderSelectionRuleType.Lines: { QueueOrderSelectionMostLines tempcfg = scorerConfig as QueueOrderSelectionMostLines; return(() => { return Score(tempcfg, stationAssignment); }); } case QueueOrderSelectionRuleType.Related: { QueueOrderSelectionRelated tempcfg = scorerConfig as QueueOrderSelectionRelated; return(() => { return Score(tempcfg, stationAssignment); }); } default: throw new ArgumentException("Unknown scorer type: " + scorerConfig.Type().ToString()); } }
private double Score(QueueOrderSelectionFCFS config, bool queueAssignment) { // Simply use the inverted arrival timestamp as the score return(-_currentOrder.TimeStamp); }