public bool TransitiveArcExist(Arc arc) { MachineOccupation ending = Solution .GetOperation(arc.Tail - 1) .EndingMachineOccupations .FirstOrDefault(occ => occ.MachineId == arc.MachineId); MachineOccupation starting = Solution .GetOperation(arc.Head) .StartingMachineOccupations .FirstOrDefault(occ => occ.MachineId == arc.MachineId); // guess this is possible due to changed routes... if (starting == null || ending == null) { return(false); } var result = SequencingLayer.TransitiveArcExist(ending, starting); #if DEBUG if (JobShopChecks.On) { var checkedResult = Graph.PathExists( RoutingLayer.ClosureLayer.SequencingLayer.GraphLayer, arc.Tail, arc.Head); Assert(JobShopChecks, result == checkedResult, "A transitive arc check must return the same result as a simple dfs path search."); } #endif return(result); }
public TimeSpan GetMachineReleaseTime(MachineOccupation first, MachineOccupation second) { Assert(SolutionChecks, first.MachineId == second.MachineId, "first.MachineId == second.MachineId"); return(first.ReleaseTime); // I changed this to always return the fixed release time which is also the connection time. this solves the // problem of the determining the termination criterion, as now all setup times are sequence independent. // penalties for missed connections will be added as soft penalties from the sequencing layer. //if (first.Type != MachineOccupationType.ConnectionTarget) return first.ReleaseTime; //return _missedConnectionPenalty; }
private Arc InsertSingleOccupation(MachineOccupation occupation, out Arc otherInsertedArc) { var mId = occupation.MachineId; var latestEntryNoDelay = Solution.GetOperation(occupation.LastOperation + 1).LatestEntry; var next = SequencingLayer[mId] .FirstOrDefault(o => // release time of 'o' Solution.GetEntryTime(o.FirstOperation) > latestEntryNoDelay); // CASE 0: insert into an empty list. if (SequencingLayer[mId].Count == 0) { otherInsertedArc = SequencingLayer[mId].InsertFront(occupation); // hence, no disjunctive arcs are inserted (no arcs inserted) return(default);
public bool TransitiveArcExist(MachineOccupation fst, MachineOccupation snd) { Assert(SequencingChecks, fst.MachineId == snd.MachineId); return(_sequences[fst.MachineId].TransitiveArcExist(fst, snd)); }
public Operation( int id, int jobId, IOperation operation, TimeSpan actualEarliestEntryTime, TimeSpan actualLatestEntryTime, // given the Operation.Id and the resp Machine, return the Occupation Func <int, int, TimeSpan, MachineOccupation> getMachineOccupation, ref List <MachineOccupation> currentOccupations, // given a IMachine lookup its new id Func <IMachine, int> machineIdLookup, Func <IConnection, BjsConnection> connectionLookup, bool loadConnections) { Id = id; Runtime = operation.Runtime; DelayWeight = operation.DelayWeight; EarliestEarliestEntry = actualEarliestEntryTime; LatestEntry = actualLatestEntryTime; Machines = operation.Machines.Select(m => new IntMachine(machineIdLookup(m), m.ReleaseTime)).ToArray(); // Starting occupations first, some might end here directly. List <MachineOccupation> startingHere = new List <MachineOccupation>(); foreach (var m in Machines) { if (currentOccupations.Select(c => c.MachineId).Contains(m.Id)) { continue; } startingHere.Add(getMachineOccupation(id, m.Id, m.ReleaseTime)); } currentOccupations.AddRange(startingHere); // Ending occupations: var endingHere = currentOccupations.Where(m => m.LastOperation == Id).ToList(); currentOccupations = currentOccupations.Except(endingHere).ToList(); // Connections: OutgoingConnections = !loadConnections ? new BjsConnection[0] : (operation.OutgoingConnections? .Where(c => c != null).Select(connectionLookup).ToArray() ?? new BjsConnection[0]); IncomingConnections = !loadConnections ? new BjsConnection[0] : (operation.IncomingConnections? .Where(c => c != null).Select(connectionLookup).ToArray() ?? new BjsConnection[0]); foreach (BjsConnection connection in OutgoingConnections) { MachineOccupation occ = new MachineOccupation(id, id, connection.Id, jobId, MachineOccupationType.ConnectionOrigin, connection.Length); startingHere.Add(occ); endingHere.Add(occ); } foreach (BjsConnection connection in IncomingConnections) { MachineOccupation occ = new MachineOccupation(id, id, connection.Id, jobId, MachineOccupationType.ConnectionTarget, TimeSpan.Zero); startingHere.Add(occ); endingHere.Add(occ); } StartingMachineOccupations = startingHere.ToArray(); EndingMachineOccupations = endingHere.ToArray(); }