Example #1
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);
 }
Example #2
0
 private bool PotentialCausingCollision(ICraneAgent other)
 {
     if (GoalPosition1 < _crane.GirderPosition && other.GetGirderPosition() < GetGirderPosition())
     {
         // crane may cause collision with other in two cases
         if (other.GoalPosition1 <= other.GetGirderPosition())
         {
             // 0 .... <-other .... <-crane .... MAX
             return(other.GetGirderPosition() + other.Width / 2 > Math.Min(Math.Min(GoalPosition1, GoalPosition2), TargetPosition) - Width / 2);
         }
         else
         {
             // 0 .... other-> .... <-crane .... MAX
             return(Math.Max(Math.Max(other.GoalPosition1, other.GoalPosition2), other.TargetPosition) + other.Width / 2 > Math.Min(Math.Min(GoalPosition1, GoalPosition2), TargetPosition) - Width / 2);
         }
     }
     else if (GoalPosition1 > _crane.GirderPosition && other.GetGirderPosition() > GetGirderPosition())
     {
         // crane may cause collision with other in two cases
         if (other.GoalPosition1 >= other.GetGirderPosition())
         {
             // 0 .... crane-> .... other-> .... MAX
             return(other.GetGirderPosition() - other.Width / 2 < Math.Max(Math.Max(GoalPosition1, GoalPosition2), TargetPosition) + Width / 2);
         }
         else
         {
             // 0 .... crane-> .... <-other .... MAX
             return(Math.Min(Math.Min(other.GoalPosition1, other.GoalPosition2), other.TargetPosition) - other.Width / 2 < Math.Max(Math.Max(GoalPosition1, GoalPosition2), TargetPosition) + Width / 2);
         }
     }
     return(false);
 }
Example #3
0
        public virtual double GetClosestToTarget(ICraneAgent agent, double to)
        {
            var pos = agent.GetGirderPosition();

            foreach (var u in Users)
            {
                if (IsOverlap(u.LowerPosition, u.HigherPosition, Math.Min(pos, to), Math.Max(pos, to)))
                {
                    if (u.LowerPosition < pos && pos < u.HigherPosition)
                    {
                        World.Environment.Log($"WARNING: Crane {agent.Id} at position {pos} is within blocked zone [{u.LowerPosition}; {u.HigherPosition}] -> should not be!");
                        return(pos);
                    }
                    to = to > pos ? u.LowerPosition : u.HigherPosition;
                }
            }
            return(to);
        }