Commit e56eef9d authored by Tong Li's avatar Tong Li

解码优化

parent 103266f2
...@@ -22,7 +22,7 @@ public class FileHelper { ...@@ -22,7 +22,7 @@ public class FileHelper {
String filePath = LOG_FILE_PATH + date + LOG_FILE; String filePath = LOG_FILE_PATH + date + LOG_FILE;
try (PrintWriter writer = new PrintWriter(new FileWriter(filePath, true))) { try (PrintWriter writer = new PrintWriter(new FileWriter(filePath, true))) {
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
writer.println("[" + timestamp + "] " + message); writer.println("[" + timestamp + "] " + message);
System.out.println("[" + timestamp + "] " + message); System.out.println("[" + timestamp + "] " + message);
......
...@@ -118,11 +118,11 @@ public class GeneticAlgorithm { ...@@ -118,11 +118,11 @@ public class GeneticAlgorithm {
FileHelper.writeLogFile("初始化种群-----------开始-------"); FileHelper.writeLogFile("初始化种群-----------开始-------");
// 步骤1:初始化种群 // 步骤1:初始化种群
// List<Chromosome> population = initialization.generateInitialPopulation(param, globalOpList); List<Chromosome> population = initialization.generateInitialPopulation(param, globalOpList);
// 步骤1:使用构造启发式算法生成初始种群 // 步骤1:使用构造启发式算法生成初始种群
FileHelper.writeLogFile("构造启发式初始化-----------开始-------"); FileHelper.writeLogFile("构造启发式初始化-----------开始-------");
List<Chromosome> population = initialization.generateHeuristicInitialPopulation(param, globalOpList); // List<Chromosome> population = initialization.generateHeuristicInitialPopulation(param, globalOpList);
FileHelper.writeLogFile("构造启发式初始化-----------结束-------"); FileHelper.writeLogFile("构造启发式初始化-----------结束-------");
...@@ -477,7 +477,7 @@ return population; ...@@ -477,7 +477,7 @@ return population;
FileHelper.writeLogFile("解码---------------"+population.size() ); FileHelper.writeLogFile("解码---------------"+population.size() );
GeneticDecoder decoder = new GeneticDecoder(_GlobalParam, param.getBaseTime(), machines, orders, materials, machineScheduler,materialRequirementService, sceneId); GeneticDecoder decoder = new GeneticDecoder(_GlobalParam, param.getBaseTime(), machines, orders, materials, machineScheduler,materialRequirementService, sceneId);
boolean ismore=true; boolean ismore=false;
if(ismore) { if(ismore) {
CompletableFuture.allOf(population.stream() CompletableFuture.allOf(population.stream()
.map(chromosome -> CompletableFuture.runAsync(() -> decode(decoder, chromosome, param, allOperations, globalOpList), decodeExecutor)) .map(chromosome -> CompletableFuture.runAsync(() -> decode(decoder, chromosome, param, allOperations, globalOpList), decodeExecutor))
......
...@@ -1140,7 +1140,7 @@ if(headers1==null) ...@@ -1140,7 +1140,7 @@ if(headers1==null)
* @return 包含物料需求列表和子订单列表的结果对象(替代C#的out参数) * @return 包含物料需求列表和子订单列表的结果对象(替代C#的out参数)
*/ */
public void EditOperationBOM(Entry operation,Chromosome chromosome,LocalDateTime earliestStartTime,GeneticDecoder coder) { public void EditOperationBOM(Entry operation,Chromosome chromosome,LocalDateTime earliestStartTime,GeneticDecoder coder,Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache) {
List<OrderMaterialRequirement> materialRequirements = new ArrayList<>(); List<OrderMaterialRequirement> materialRequirements = new ArrayList<>();
String sceneId=chromosome.getScenarioID(); String sceneId=chromosome.getScenarioID();
...@@ -1319,7 +1319,7 @@ if(headers1==null) ...@@ -1319,7 +1319,7 @@ if(headers1==null)
for (Integer orderid : orderids) { for (Integer orderid : orderids) {
coder.ClearorderOperationResult(chromosome, orderid); coder.ClearorderOperationResult(chromosome, orderid);
coder.EditorderOperation(chromosome, orderid, needed); coder.EditorderOperation(chromosome, orderid, needed,machineTasksCache);
} }
}else { }else {
......
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