Ejemplo n.º 1
0
 public BrpState(BrpState source)
 {
     HandoverId   = source.HandoverId;
     ProductionId = source.ProductionId;
     Moves        = source.Moves.ToList();
     Stacks       = source.Stacks.Select(s => new Stack(s)).ToArray();
 }
Ejemplo n.º 2
0
        /// Does a simple depth first search using forced moves starting from the initial BrpState.
        public List <CraneMove> DepthFirstSearch(BrpState initial)
        {
            var budget            = 10000;
            List <CraneMove> best = null;
            var stack             = new Stack <BrpState>();

            stack.Push(initial);

            while (stack.Count > 0 && budget > 0)
            {
                budget -= 1;
                var state = stack.Pop();
                if (state.IsSolved)
                {
                    if (best == null || best.Count > state.Moves.Count)
                    {
                        best = state.Moves;
                    }
                }
                else
                {
                    foreach (var move in state.ForcedMoves())
                    {
                        stack.Push(state.Apply(move));
                    }
                }
            }

            return(best);
        }
Ejemplo n.º 3
0
        /// Generate a schedule for the current world state by solving an restricted offline BRP
        public void CalculateSchedule(CraneSchedule schedule)
        {
            var priorities  = PrioritizeByDueDate();
            var initalState = new BrpState(world, priorities);
            var solution    = DepthFirstSearch(initalState);

            FillScheduleFromSolution(solution, schedule);
        }
Ejemplo n.º 4
0
        public BrpState Apply(CraneMove move)
        {
            var result = new BrpState(this);
            var block  = result.Stacks[move.SourceId].Blocks.Pop();

            if (move.TargetId != HandoverId)
            {
                result.Stacks[move.TargetId].Blocks.Push(block);
            }
            result.Moves.Add(move);
            return(result);
        }