Commit 5c497ad5 authored by Tong Li's avatar Tong Li

优化

parent 22c58033
...@@ -275,7 +275,21 @@ public class GeneticAlgorithm { ...@@ -275,7 +275,21 @@ public class GeneticAlgorithm {
} }
private List<Chromosome> chromosomeDistinct(List<Chromosome> population) private List<Chromosome> chromosomeDistinct(List<Chromosome> population)
{ {
if(population==null)
{
FileHelper.writeLogFile(String.format("排产-----------方案数量---%d-------",0 ));
return population;
}
FileHelper.writeLogFile(String.format("排产-----------方案数量---%d-------",population.size() ));
List<Chromosome> population1 = population.stream().filter(t->t.getGeneStr()==null).collect(Collectors.toList());
if(population1!=null&&population1.size()>0)
{
FileHelper.writeLogFile(String.format("排产-----------方案GeneStrnull数量---%d-------",population1.size() ));
}
population = population.stream() population = population.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
Chromosome::getGeneStr, // key:去重的字段(GeneStr) Chromosome::getGeneStr, // key:去重的字段(GeneStr)
...@@ -285,12 +299,27 @@ public class GeneticAlgorithm { ...@@ -285,12 +299,27 @@ public class GeneticAlgorithm {
.values() // 获取去重后的 .values() // 获取去重后的
.stream() .stream()
.collect(Collectors.toList()); .collect(Collectors.toList());
FileHelper.writeLogFile(String.format("排产-----------方案数量---%d-------",population.size() ));
return population; return population;
} }
private List<Chromosome> chromosomeDistinct1(List<Chromosome> population) private List<Chromosome> chromosomeDistinct1(List<Chromosome> population)
{ {
if(population==null)
{
FileHelper.writeLogFile(String.format("排产-----------方案数量---%d-------",0 ));
return population;
}
FileHelper.writeLogFile(String.format("排产-----------方案数量---%d-------",population.size() ));
List<Chromosome> population1 = population.stream().filter(t->t.getGeneStr()==null).collect(Collectors.toList());
if(population1!=null&&population1.size()>0)
{
FileHelper.writeLogFile(String.format("排产-----------方案GeneStrnull数量---%d-------",population1.size() ));
}
population = population.stream() population = population.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
Chromosome::getGeneStr, // key:去重的字段(GeneStr) Chromosome::getGeneStr, // key:去重的字段(GeneStr)
...@@ -300,6 +329,7 @@ public class GeneticAlgorithm { ...@@ -300,6 +329,7 @@ public class GeneticAlgorithm {
.values() // 获取去重后的 .values() // 获取去重后的
.stream() .stream()
.collect(Collectors.toList()); .collect(Collectors.toList());
FileHelper.writeLogFile(String.format("排产-----------方案数量---%d-------",population.size() ));
return population; return population;
} }
...@@ -355,6 +385,7 @@ public class GeneticAlgorithm { ...@@ -355,6 +385,7 @@ public class GeneticAlgorithm {
if (chromosome==null){ if (chromosome==null){
System.out.println("chromosome==null"); System.out.println("chromosome==null");
return;
} }
chromosome.setResult(new CopyOnWriteArrayList<>()); chromosome.setResult(new CopyOnWriteArrayList<>());
......
...@@ -39,7 +39,7 @@ public class PlanResultServiceTest { ...@@ -39,7 +39,7 @@ public class PlanResultServiceTest {
// nsgaiiUtils.Test(); // nsgaiiUtils.Test();
//planResultService.execute2("C5FB5EF2A7334A0A92F826F4937E1008"); //planResultService.execute2("C5FB5EF2A7334A0A92F826F4937E1008");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66"); // planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
planResultService.execute2("54476C9F81714EDC8597F5323015F58F"); planResultService.execute2("13CC1CF783CE40D7AE3264D09FAA6378");
// LocalDateTime t= LocalDateTime.of(2025, 11, 15, 6, 51, 11); // LocalDateTime t= LocalDateTime.of(2025, 11, 15, 6, 51, 11);
// List<Integer> opids=new ArrayList<>();BCA6FA43FFA444D3952CF8F6E1EA291B // List<Integer> opids=new ArrayList<>();BCA6FA43FFA444D3952CF8F6E1EA291B
// opids.add(1); // opids.add(1);
......
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