ソースを参照

APS平台新模型约束优化

fangpy 1 年間 前
コミット
61ea4ad960

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

@@ -68,7 +68,7 @@ public class ApsBalancingApplication {
             }
         }
         System.out.println("1111111");*/
-        LocalDateTime now = LocalDateTime.now();
+        /*LocalDateTime now = LocalDateTime.now();
         List<EquipmentRunTime> allRunTimes = new ArrayList<>();
         EquipmentRunTime eq1 = new EquipmentRunTime();
         eq1.setStartRunTime(now.plusMinutes(3));
@@ -79,7 +79,8 @@ public class ApsBalancingApplication {
         allRunTimes.add(eq1);allRunTimes.add(eq2);allRunTimes.add(eq3);
         System.out.println(allRunTimes);
         allRunTimes.sort(Comparator.comparing(EquipmentRunTime::getStartRunTime));
-        System.out.println(allRunTimes);
+        System.out.println(allRunTimes);*/
+        System.out.println(DateUtil.now());
     }
 
     public static void testAps(){

+ 14 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/listener/TaskStartTimeListener.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
 import com.rongwei.rwapsserver.aps.domain.ApsSolution;
 import com.rongwei.rwapsserver.aps.domain.EquipmentRunTime;
 import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
+import lombok.extern.slf4j.Slf4j;
 import org.optaplanner.core.api.domain.variable.VariableListener;
 import org.optaplanner.core.api.score.director.ScoreDirector;
 import java.time.LocalDateTime;
@@ -13,6 +14,7 @@ import java.util.*;
 /**
  * 设备赋值后任务起止时间自动计算
  */
+@Slf4j
 public class TaskStartTimeListener implements VariableListener<ApsSolution, ProductionProcesses> {
 
     @Override
@@ -113,9 +115,14 @@ public class TaskStartTimeListener implements VariableListener<ApsSolution, Prod
                                 }
                             }
                         }
+                        /*if("6473acca9af24b95956a891520b21357".equals(previousProcess.getId())){
+                            log.info("最大等待时间处理-当前工序开始时间:"+startTime);
+                        }*/
                         scoreDirector.beforeVariableChanged(process, "startTime");
                         previousProcess.setStartTime(startTime);
                         scoreDirector.afterVariableChanged(process, "startTime");
+                        // 递归前道工序时间处理
+//                        preProcessCheck(scoreDirector,previousProcess);
                     }
                 }
             }
@@ -385,6 +392,13 @@ public class TaskStartTimeListener implements VariableListener<ApsSolution, Prod
                 }
                 toUpdateStartTime = proStartTime;
             }
+
+            /*if("6473acca9af24b95956a891520b21357".equals(process.getId())){
+                log.info("前道工序开始时间:"+process.getPreviousProcesses().get(0).getStartTime());
+                log.info("前道工序结束时间:"+process.getPreviousProcesses().get(0).getEndTime());
+
+                log.info("当前工序开始时间:"+toUpdateStartTime);
+            }*/
         }
         return toUpdateStartTime;
     }

+ 3 - 3
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/score/ApsConstraintProvider.java

@@ -31,7 +31,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
                 seriesProduce(constraintFactory),
                 lzTimeLessMaxWait(constraintFactory),
                 equipmentRunTime(constraintFactory),
-//                balancedEqUse(constraintFactory),
+                balancedEqUse(constraintFactory),
 //                mergeProcess(constraintFactory)
 
 //                mergeSame(constraintFactory),
@@ -360,7 +360,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
 
                     return bln;
                 })
-                .penalize(HardSoftScore.ONE_HARD,(productionProcesses) -> 80)
+                .penalize(HardSoftScore.ONE_HARD,(productionProcesses) -> 40)
                 .asConstraint("hasOnePreGbAfterNow");
     }
 
@@ -569,7 +569,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
                 .groupBy(ProductionProcesses::getEquipmentId,count())
                 .filter((productionProcesses, num) -> num > 1)
                 .penalize(HardSoftScore.ONE_SOFT,
-                        (productionProcesses, num) -> num * 50)
+                        (productionProcesses, num) -> 1)
                 .asConstraint("balancedEqUse");
     }
 

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

@@ -56,6 +56,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
                 .withConstraintProviderClass(ApsConstraintProvider.class)
 //                .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(10L))
                 .withTerminationSpentLimit(Duration.ofSeconds(planSeconds))
+//                .withMoveThreadCount("4")
         );
         Solver<ApsSolution> solver = solverFactory.buildSolver();
         // optaplanner 求解器数据装配

+ 4 - 1
rw-aps-server/src/main/resources/logback-spring.xml

@@ -28,7 +28,10 @@
         <appender-ref ref="logFile" />
     </logger>
 
-    <root level="debug">
+    <!--<logger name="org.optaplanner" level="trace"/>-->
+    <logger name="org.optaplanner" level="info"/>
+
+    <root level="info">
         <appender-ref ref="console"/>
         <appender-ref ref="logFile" />
     </root>