Commit f1998b61 authored by Tong Li's avatar Tong Li

变邻域+模拟退火+禁忌搜索

parent 8a7de711
...@@ -157,6 +157,11 @@ public class Order { ...@@ -157,6 +157,11 @@ public class Order {
*/ */
private boolean newCreate = false; private boolean newCreate = false;
/**
* 是否新创建半成品,默认值:false
*/
private boolean newSfCreate = false;
/** /**
* 是否创建BOM,默认值:false * 是否创建BOM,默认值:false
*/ */
......
...@@ -266,7 +266,7 @@ public class GeneticDecoder { ...@@ -266,7 +266,7 @@ public class GeneticDecoder {
Initialization initialization=new Initialization(); Initialization initialization=new Initialization();
initialization.generateInitialSFPopulation(chromosome,globalOpList); initialization.generateInitialSFPopulation(chromosome,globalOpList);
chromosome.getGlobalOpList().addAll(globalOpList); chromosome.getGlobalOpList().addAll(globalOpList);
return 1; return 1;
} }
private void CreateNewOpSequence(Chromosome chromosome) private void CreateNewOpSequence(Chromosome chromosome)
...@@ -279,10 +279,10 @@ return 1; ...@@ -279,10 +279,10 @@ return 1;
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
if(finishedOrder==null||finishedOrder.size()==0) if(finishedOrder==null||finishedOrder.size()==0)
{ {
return; return;
} }
List<Integer> oldSequence=chromosome.getOperationSequencing(); List<Integer> oldSequence=chromosome.getOperationSequencing();
List<Integer> finalSequence = new ArrayList<>(); List<Integer> finalSequence = new ArrayList<>();
...@@ -391,7 +391,7 @@ if(finishedOrder==null||finishedOrder.size()==0) ...@@ -391,7 +391,7 @@ if(finishedOrder==null||finishedOrder.size()==0)
public void serialDecode(Chromosome chromosome) { public void serialDecode(Chromosome chromosome) {
// List<OrderMaterialRequirement> orderMaterials = materialRequirementService.buildMultiLevelRequirementNetwork(chromosome, sceneId, baseTime,_globalParam); List<OrderMaterialRequirement> orderMaterials = materialRequirementService.buildMultiLevelRequirementNetwork(chromosome, sceneId, baseTime,_globalParam);
chromosome.setScenarioID(sceneId); chromosome.setScenarioID(sceneId);
if(_globalParam.isIsCheckSf()) { if(_globalParam.isIsCheckSf()) {
int isnew= generateGlobalOpList(chromosome); int isnew= generateGlobalOpList(chromosome);
...@@ -1014,7 +1014,7 @@ if(finishedOrder==null||finishedOrder.size()==0) ...@@ -1014,7 +1014,7 @@ if(finishedOrder==null||finishedOrder.size()==0)
prevtime = Math.max(prevtime, bomtime); prevtime = Math.max(prevtime, bomtime);
Machine machine = machineIdMap.get(machineId); Machine machine = machineIdMap.get(machineId);
int actualEndTime = processWithSingleMachine(currentOp, machine, processTime, prevtime,machineOption, chromosome,false,prevendtime,machineTasksCache,entryIndexById, scheduleIndexById); int actualEndTime = processWithSingleMachine(currentOp, machine, processTime, prevtime,machineOption, chromosome,false,prevendtime,machineTasksCache,entryIndexById, scheduleIndexById);
return actualEndTime; return actualEndTime;
} }
...@@ -1474,9 +1474,9 @@ return actualEndTime; ...@@ -1474,9 +1474,9 @@ return actualEndTime;
{ {
return 0; return 0;
} }
LocalDateTime earliestStartTime1=baseTime.plusSeconds(earliestStartTime); LocalDateTime earliestStartTime1=baseTime.plusSeconds(earliestStartTime);
materialRequirementService.EditOperationBOM(currentOp,chromosome,earliestStartTime1,this,machineTasksCache, entryIndexById, scheduleIndexById); materialRequirementService.EditOperationBOM(currentOp,chromosome,earliestStartTime1,this,machineTasksCache, entryIndexById, scheduleIndexById, baseTime);
return getOperationBOMTime(currentOp, chromosome); return getOperationBOMTime(currentOp, chromosome);
} }
...@@ -1576,10 +1576,10 @@ return getOperationBOMTime(currentOp, chromosome); ...@@ -1576,10 +1576,10 @@ return getOperationBOMTime(currentOp, chromosome);
&& t.getProductOrderID() != null && !t.getProductOrderID().isEmpty() && t.getProductOrderID() != null && !t.getProductOrderID().isEmpty()
) )
.collect(Collectors.toList()); .collect(Collectors.toList());
if(MaterialRequirements==null||MaterialRequirements.size()==0) if(MaterialRequirements==null||MaterialRequirements.size()==0)
{ {
continue; continue;
} }
for (OrderMaterialRequirement orderMaterial:MaterialRequirements) { for (OrderMaterialRequirement orderMaterial:MaterialRequirements) {
List<Integer> orderids= orderMaterial.getProductOrderID(); List<Integer> orderids= orderMaterial.getProductOrderID();
if(orderids!=null&&orderids.size()>0) { if(orderids!=null&&orderids.size()>0) {
...@@ -2332,7 +2332,7 @@ if(MaterialRequirements==null||MaterialRequirements.size()==0) ...@@ -2332,7 +2332,7 @@ if(MaterialRequirements==null||MaterialRequirements.size()==0)
.filter(t -> orderIds.contains(t.getOrderId())) .filter(t -> orderIds.contains(t.getOrderId()))
.max(Comparator.comparing(Order::getDueDate)) .max(Comparator.comparing(Order::getDueDate))
.orElse(null); .orElse(null);
if (order.isNewCreate()) { if (order.isNewSfCreate()) {
continue; continue;
} }
LocalDateTime dueDateTime = order.getDueDate(); LocalDateTime dueDateTime = order.getDueDate();
......
...@@ -25,6 +25,10 @@ public class GeneticOperations { ...@@ -25,6 +25,10 @@ public class GeneticOperations {
private static ScheduleParams param; private static ScheduleParams param;
public GeneticOperations() {
}
public GeneticOperations(GlobalParam globalParam,List<Entry> _allOperations,ScheduleParams _param) { public GeneticOperations(GlobalParam globalParam,List<Entry> _allOperations,ScheduleParams _param) {
_GlobalParam=globalParam; _GlobalParam=globalParam;
allOperations = _allOperations; allOperations = _allOperations;
...@@ -424,10 +428,12 @@ public class GeneticOperations { ...@@ -424,10 +428,12 @@ public class GeneticOperations {
public void DelOrder(Chromosome chromosome) { public void DelOrder(Chromosome chromosome) {
List<Entry> allOperations = chromosome.getAllOperations(); List<Entry> allOperations = chromosome.getAllOperations();
List<GlobalOperationInfo> globalOpList= chromosome.getGlobalOpList(); List<GlobalOperationInfo> globalOpList= chromosome.getGlobalOpList();
if(chromosome.getOrders()==null||chromosome.getOrders().size()==0)
return;
List<Order> orders = chromosome.getOrders(); List<Order> orders = chromosome.getOrders();
List<Integer> OperationSequencing= chromosome.getOperationSequencing(); List<Integer> OperationSequencing= chromosome.getOperationSequencing();
List<Integer> newoorderids= orders.stream() List<Integer> newoorderids= orders.stream()
.filter(t->t.isNewCreate()) .filter(t->t.isNewSfCreate())
.map(Order::getId) .map(Order::getId)
.sorted(Comparator.reverseOrder()) .sorted(Comparator.reverseOrder())
.collect(Collectors.toList()); .collect(Collectors.toList());
......
...@@ -894,7 +894,7 @@ public class MaterialRequirementServicebf { ...@@ -894,7 +894,7 @@ public class MaterialRequirementServicebf {
childorder.setQuantity((int) orderMaterial.getQjQty()); childorder.setQuantity((int) orderMaterial.getQjQty());
childorder.setFinishOrderId(new ArrayList<>()); childorder.setFinishOrderId(new ArrayList<>());
childorder.getFinishOrderId().add(forder.getId()); childorder.getFinishOrderId().add(forder.getId());
childorder.setNewCreate(true); childorder.setNewSfCreate(true);
childorder.setTargetFinishedOperationId(new ArrayList<>()); childorder.setTargetFinishedOperationId(new ArrayList<>());
childorder.getTargetFinishedOperationId().add(operation.getId()); childorder.getTargetFinishedOperationId().add(operation.getId());
childorder.setSerie(forder.getSerie()); childorder.setSerie(forder.getSerie());
......
...@@ -238,7 +238,7 @@ public class PlanResultService { ...@@ -238,7 +238,7 @@ public class PlanResultService {
_sceneService.saveChromosomeToFile(chromosome, SceneId); _sceneService.saveChromosomeToFile(chromosome, SceneId);
WriteScheduleSummary(chromosome); // WriteScheduleSummary(chromosome);
return chromosome; return chromosome;
......
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