Commit 7484ece0 authored by Tong Li's avatar Tong Li

变领域优化

parent b17004da
......@@ -595,53 +595,58 @@ public class GeneticOperations {
return indexWeights.get(CommonCalculator.getOsIndex(indexWeights));
}
public void DelOrder(Chromosome chromosome) {
List<Entry> allOperations = chromosome.getAllOperations();
List<GlobalOperationInfo> globalOpList= chromosome.getGlobalOpList();
if(chromosome.getOrders()==null||chromosome.getOrders().size()==0)
return;
List<Order> orders = chromosome.getOrders();
List<Integer> OperationSequencing= chromosome.getOperationSequencing();
log("删除前"+OperationSequencing.size(),true);
log(String.format("半成品订单-删除前,工序: %d,工序序列: %d,设备: %d,设备序列: %d",
allOperations.size(), OperationSequencing.size(),globalOpList.size(),chromosome.getMachineSelection().size()),true);
List<Integer> newoorderids= orders.stream()
.filter(t->t.isNewSfCreate())
.map(Order::getId)
.sorted(Comparator.reverseOrder())
.collect(Collectors.toList());
if(newoorderids!=null&&newoorderids.size()>0) {
List<Entry> allOperations = chromosome.getAllOperations();
List<GlobalOperationInfo> globalOpList = chromosome.getGlobalOpList();
List<Integer> OperationSequencing = chromosome.getOperationSequencing();
log(String.format("半成品订单-删除前,工序: %d,工序序列: %d,设备: %d,设备序列: %d",
allOperations.size(), OperationSequencing.size(), globalOpList.size(), chromosome.getMachineSelection().size()), true);
for (Integer id : newoorderids) {
List<Entry> sourceOps = allOperations.stream()
.filter(o -> o.getGroupId()==id)
.filter(o -> o.getGroupId() == id)
.sorted(Comparator.comparing(Entry::getSequence))
.collect(Collectors.toList());
for (Entry entry : sourceOps) {
OptionalInt index1 = IntStream.range(0, globalOpList.size())
.filter(h -> entry.getId()==globalOpList.get(h).getOp().getId())
.filter(h -> entry.getId() == globalOpList.get(h).getOp().getId())
.findFirst();
globalOpList.remove((int)index1.orElse(0));
globalOpList.remove((int) index1.orElse(0));
chromosome.getMachineSelection().remove((int)index1.orElse(0));
chromosome.getMachineSelection().remove((int) index1.orElse(0));
}
chromosome.getOperatRel().remove(id-1);
chromosome.getOperatRel().remove(id - 1);
}
allOperations.removeIf(t ->newoorderids.contains(t.getGroupId()));
OperationSequencing.removeIf(t ->newoorderids.contains(t));
allOperations.removeIf(t -> newoorderids.contains(t.getGroupId()));
OperationSequencing.removeIf(t -> newoorderids.contains(t));
AtomicInteger globalOpId = new AtomicInteger(0);
globalOpList.forEach(t-> {
globalOpList.forEach(t -> {
t.setGlobalOpId(globalOpId.getAndIncrement());
});
orders.removeIf(t ->newoorderids.contains(t.getId()));
orders.removeIf(t -> newoorderids.contains(t.getId()));
log(String.format("半成品订单-删除后,工序: %d,工序序列: %d,设备: %d,设备序列: %d",
allOperations.size(), OperationSequencing.size(), globalOpList.size(), chromosome.getMachineSelection().size()), true);
}
}
private void log(String message, boolean enableLogging) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment