Example #1
0
        /// <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());
            }
        }
Example #2
0
 private double Score(QueueOrderSelectionRelated config, bool queueAssignment)
 {
     // Prefer orders similar to the ones already in the pool
     if (queueAssignment)
     {
         // Return fraction of SKUs necessary for other orders in the queue order pool
         return(_currentOrder.Positions.Sum(p => _stationQueues[_currentStation].Any(o => o.PositionOverallCount(p.Key) > 0) ? 1 : 0) / _currentOrder.Positions.Count());
     }
     else
     {
         // Return fraction of SKUs still needed to fulfill orders already assigned to the station
         return(_currentOrder.Positions.Sum(p => _currentStation.AssignedOrders.Any(o => o.PositionOverallCount(p.Key) - o.PositionServedCount(p.Key) > 0) ? 1 : 0) / _currentOrder.Positions.Count());
     }
 }