示例#1
0
        public void RightClosureWithRemoval(Arc toBeRemoved)
        {
            Assert(InvertPrecedenceCheck, GraphLayer.ArcExists(toBeRemoved.Tail, toBeRemoved.Head, toBeRemoved.MachineId));
            Assert(BeforeRemovalAcyclic, GraphLayer.IsAcyclic());

            var arcs = SwapInMate(toBeRemoved);

            Assert(InvertPrecedenceCheck, !GraphLayer.ArcExists(toBeRemoved.Tail, toBeRemoved.Head, toBeRemoved.MachineId));

            //var criterion = arcs.Select(a => Solution.GetEntryTime(a.Head) + Solution.GetOperation(a.Head).RunTime + TimeSpan.FromTicks(1)).Max();

            RightClosure(arcs[1], true, default);

            Assert(InvertPrecedenceCheck, !GraphLayer.ArcExists(toBeRemoved.Tail, toBeRemoved.Head, toBeRemoved.MachineId));
            Assert(AfterRemoveAcyclic, GraphLayer.IsAcyclic(), "GraphLayer.IsAcyclic()");
        }
示例#2
0
        public void LeftClosureWithRemoval(Arc toBeRemoved)
        {
            Assert(InvertPrecedenceCheck, GraphLayer.ArcExists(toBeRemoved.Tail, toBeRemoved.Head, toBeRemoved.MachineId));
            Assert(BeforeRemovalAcyclic, GraphLayer.IsAcyclic());

            if (!GraphLayer.TimesAreUpToDate())
            {
                throw new Exception();
            }


            Route route     = Solution.GetRoute(toBeRemoved.Head);
            var   criterion = route.Operations
                              .SelectMany(op => GraphLayer.OutgoingArcs(op.Id))
                              .Select(a => a.Head)
                              .Distinct()
                              .Select(v => Solution.GetEntryTime(v))
                              .Max() + TimeSpan.FromTicks(1);

            var arcs = SwapInMate(toBeRemoved);

            var otherCriterion = route.Operations
                                 .SelectMany(op => GraphLayer.OutgoingArcs(op.Id))
                                 .Select(a => a.Head)
                                 .Distinct()
                                 .Select(v => Solution.GetEntryTime(v))
                                 .Max() + TimeSpan.FromTicks(1);

            Assert(InvertPrecedenceCheck, !GraphLayer.ArcExists(toBeRemoved.Tail, toBeRemoved.Head, toBeRemoved.MachineId));

            //var criterion = arcs.Select(a => Solution.GetEntryTime(a.Head) + Solution.GetOperation(a.Head).RunTime + TimeSpan.FromTicks(1)).Max();

            LeftClosure(arcs[1], useTerminationCriterion: true, criterion);

            Assert(InvertPrecedenceCheck, !GraphLayer.ArcExists(toBeRemoved.Tail, toBeRemoved.Head, toBeRemoved.MachineId));

            if (!GraphLayer.IsAcyclic())
            {
                Console.WriteLine($"Cycle detected, visualizing");
                Console.WriteLine($"Termination criterion = {criterion.Show()}");
                GraphLayer.Visualize(GraphVisualization.NeighbourSelector(GraphLayer, route, 2));
            }

            Assert(AfterRemoveAcyclic, GraphLayer.IsAcyclic());
        }