コード例 #1
0
        private ICraneAgent CraneAssignmentHeuristic(ICraneMoveEvent order)
        {
            if (order.RequiredCraneId.HasValue)
            {
                // there is a required crane assigned to complete this order
                return(_world.CraneAgents.Single(x => x.Id == order.RequiredCraneId.Value));
            }

            foreach (var agent in _world.CraneAgents.Where(x => IsExecutable(order, x))
                     .OrderBy(x => Math.Abs(x.GetGirderPosition() - order.PickupGirderPosition) + Math.Abs(x.GetGirderPosition() - order.DropoffGirderPosition)))
            {
                return(agent);
            }

            return(null);
        }
コード例 #2
0
        private IEnumerable <Event> RemoveFromSchedule(ICraneMoveEvent move)
        {
            yield return(move.Finished);

            Schedule.Remove(move.Id);
            Environment.MoveFinished(move.Id, move.Finished.IsOk);
            foreach (var m in Environment.CraneMoves)
            {
                m.RemoveFromPredecessors(move.Id);
            }
            TriggerWhenChange();
            if (Schedule.Tasks == 0)
            {
                TriggerWhenEmpty();
            }
            Environment.Environment.ActiveProcess.HandleFault();
        }
コード例 #3
0
 private bool IsExecutable(ICraneMoveEvent move, ICraneAgent agent)
 {
     if (move.Predecessors > 0 || move.ReleaseTime > _world.Now)
     {
         return(false);
     }
     if (!agent.CanReach(move.PickupGirderPosition) || !agent.CanReach(move.DropoffGirderPosition))
     {
         return(false);
     }
     if (_world.CraneAgents.Any(other => other != agent &&
                                other.State != CraneAgentState.Waiting &&
                                ((other.GetGirderPosition() < agent.GetGirderPosition() && (Math.Max(other.GoalPosition1, other.GoalPosition2) + other.Width / 2 > Math.Min(move.PickupGirderPosition, move.DropoffGirderPosition) - agent.Width / 2)) ||
                                 (other.GetGirderPosition() > agent.GetGirderPosition() && (Math.Min(other.GoalPosition1, other.GoalPosition2) - other.Width / 2 < Math.Max(move.PickupGirderPosition, move.DropoffGirderPosition) + agent.Width / 2)))))
     {
         return(false);
     }
     return(true);
 }
コード例 #4
0
 public virtual bool IsAssigned(ICraneMoveEvent move)
 {
     return(Schedule.ContainsMove(move.Id));
 }