소스 검색

连续生产约束优化

fangpy 1 년 전
부모
커밋
7a89f5ffdd

+ 2 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/ApsBalancingApplication.java

@@ -117,7 +117,8 @@ public class ApsBalancingApplication {
         System.out.println(ObjectUtil.cloneByStream(a).getId());*/
         String[] split = "1050^_^10500态热轧卷冷轧 厚6*宽1600mm 1吨^_^1600.00^_^6.0000^_^6.0000".split("\\^_\\^");
         BigDecimal i1 = new BigDecimal("1600");
-        System.out.println(i1.add(new BigDecimal("30")));
+        int cores = Runtime.getRuntime().availableProcessors();
+        System.out.println(cores);
     }
 
     public static void consTest(){

+ 3 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/impl/ProductionScheduleServiceImpl.java

@@ -57,6 +57,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         if(productionScheduleVo.getEnvironmentMode() != null && productionScheduleVo.getEnvironmentMode() == 1){
             mode = EnvironmentMode.FULL_ASSERT;
         }
+        // CPU核数
+        String cores = Runtime.getRuntime().availableProcessors() + "";
         // optaplanner 求解器配置实例化
         SolverFactory<ApsSolution> solverFactory = SolverFactory.create(new SolverConfig()
                 .withEnvironmentMode(mode)
@@ -65,7 +67,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
                 .withConstraintProviderClass(ApsConstraintProvider.class)
 //                .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(10L))
                 .withTerminationSpentLimit(Duration.ofSeconds(planSeconds))
-                .withMoveThreadCount("4")
+                .withMoveThreadCount(cores)
         );
         Solver<ApsSolution> solver = solverFactory.buildSolver();
         solver.addEventListener(new SolverEventListener<ApsSolution>() {