Commit a94f7c82 authored by Tong Li's avatar Tong Li

优化

parent ccd683c2
......@@ -504,7 +504,7 @@ public class GeneticDecoder {
public void serialDecode(Chromosome chromosome) {
long decodeStart = System.nanoTime();
chromosome.setScenarioID(sceneId);
boolean isJit=true;//_globalParam.isJit();
boolean isJit=_globalParam.isJit();
......@@ -824,7 +824,7 @@ public class GeneticDecoder {
// 倒排失败时只修复当前工序及其后道已排工序。
// 例如倒排顺序 3->2->1,2 放不下时撤回 2、3,再按 2->3 放到各自设备最后任务之后。
List<Integer> removeOp = clearOrderSchedulingFromSequence(chromosome, groupId, opSequence,
entrysBygroupId, machineTasksCache, scheduleIndexById);
entrysBygroupId, machineTasksCache, scheduleIndexById,entryIndexById);
int repairStartTime = operationResult.getStartTime();
int forwardEndTime = scheduleOrderForwardFallback(groupId, removeOp, repairStartTime, chromosome,entrysBygroupId, machineIdMap, machineTasksCache,
......@@ -910,9 +910,9 @@ public class GeneticDecoder {
Set<Integer> pendingFinishedIds = pendingReForwardMap.remove(groupId);
if (pendingFinishedIds != null && !pendingFinishedIds.isEmpty()) {
int semiEndTime = orderLastEndTime.get(groupId);
FileHelper.writeLogFile("[ReForward] 半成品" + groupId
+ "全部排完(结束时间=" + semiEndTime + "),重新正排关联成品"
+ pendingFinishedIds);
// FileHelper.writeLogFile("[ReForward] 半成品" + groupId
// + "全部排完(结束时间=" + semiEndTime + "),重新正排关联成品"
// + pendingFinishedIds);
reForwardFinishedOrders(groupId,semiEndTime, pendingFinishedIds,
chromosome, machineTasksCache, scheduleIndexById,
machineIdMap, entryIndexById, opMachineKeyMap,
......@@ -1525,7 +1525,7 @@ public class GeneticDecoder {
int failedSequence,
Map<Integer, List<Entry>> entrysBygroupId,
Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,
Map<Integer, GAScheduleResult> scheduleIndexById) {
Map<Integer, GAScheduleResult> scheduleIndexById,Map<Integer, Entry> entryIndexById) {
Set<Integer> repairOperationIds = entrysBygroupId.getOrDefault(groupId, Collections.emptyList()).stream()
.filter(op -> op.getSequence() >= failedSequence)
.map(Entry::getId)
......@@ -1537,7 +1537,7 @@ public class GeneticDecoder {
for (GAScheduleResult result : resultsToRemove) {
Entry op= entrysBygroupId.get(result.getGroupId()).get(result.getOperationId());
Entry op= entryIndexById.get(result.getOperationId());
Map<String, MaterialDeduction> deductions = readOperationStockDeductions(op);
......@@ -3750,8 +3750,8 @@ if(geneDetails!=null&&geneDetails.size()>0)
forwardFallbackOrderIds.add(finishedId);
orderSchedulingInfo.put(finishedId,
new AbstractMap.SimpleEntry<>(false, 0));
FileHelper.writeLogFile("[ReForward] 半成品" + semiOrderId
+ "倒排早于基准时间,成品" + finishedId + "重新正排,结束时间=" + forwardEndTime);
// FileHelper.writeLogFile("[ReForward] 半成品" + semiOrderId
// + "倒排早于基准时间,成品" + finishedId + "重新正排,结束时间=" + forwardEndTime);
}
reForwardFinishedOrderIds.clear();
}
......
......@@ -441,15 +441,15 @@ int start=Integer.MAX_VALUE;
semiTotalTime += ckeckLeadTime;
if (semiLatestEndTime - semiTotalTime < 0) {
FileHelper.writeLogFile("[HybridSemi] 半成品" + semiOrderId +
" 倒排开工<0,正排+成品" + finishedOrderId + "重排");
// FileHelper.writeLogFile("[HybridSemi] 半成品" + semiOrderId +
// " 倒排开工<0,正排+成品" + finishedOrderId + "重排");
reForwardFinishedOrderIds.add(finishedOrderId);
start= Math.min(start, -1);
}else {
FileHelper.writeLogFile("[HybridSemi] 半成品" + semiOrderId +
" 锚点=" + semiLatestEndTime + " (成品" + finishedOrderId +
"开始=" + finishedFirstResult.getStartTime() + ")");
// FileHelper.writeLogFile("[HybridSemi] 半成品" + semiOrderId +
// " 锚点=" + semiLatestEndTime + " (成品" + finishedOrderId +
// "开始=" + finishedFirstResult.getStartTime() + ")");
start = Math.min(start, semiLatestEndTime - ckeckLeadTime);
}
......
......@@ -631,7 +631,7 @@ public class VariableNeighborhoodSearch {
private Map<String, Object> findBottleneckMachineWithDetails(Chromosome chromosome) {
Map<String, Object> result = new HashMap<>();
List<GAScheduleResult> allResults = chromosome.getResult().stream().filter(t->!t.getCapacityTypeName().equals("Infinite")).collect(Collectors.toList());
Map<Long, Double> utilization = calculateMachineUtilization(chromosome);
Map<Long, Double> utilization = calculateMachineUtilization(chromosome,false);
Map<Long, List<GAScheduleResult>> machineOps = allResults != null ?
allResults.stream().collect(Collectors.groupingBy(GAScheduleResult::getMachineId)) :
new HashMap<>();
......@@ -1121,7 +1121,7 @@ public class VariableNeighborhoodSearch {
* 识别瓶颈设备(利用率最高的设备)
*/
private Long findBottleneckMachine(Chromosome chromosome) {
Map<Long, Double> utilization = calculateMachineUtilization(chromosome);
Map<Long, Double> utilization = calculateMachineUtilization(chromosome,false);
if (utilization.isEmpty()) {
return null;
}
......@@ -1147,11 +1147,19 @@ public class VariableNeighborhoodSearch {
/**
* 计算设备利用率
*/
private Map<Long, Double> calculateMachineUtilization(Chromosome chromosome) {
private Map<Long, Double> calculateMachineUtilization(Chromosome chromosome,boolean isInfinite) {
Map<Long, Double> utilization = new HashMap<>();
List<GAScheduleResult> results = chromosome.getResult().stream().
List<GAScheduleResult> results=new ArrayList<>();
if (isInfinite) {
results = chromosome.getResult().stream()
.collect(Collectors.toList());
}else {
results = chromosome.getResult().stream().
filter(t->!t.getCapacityTypeName().equals("Infinite"))
.collect(Collectors.toList());
}
if (results == null || results.isEmpty()) {
return utilization;
......@@ -2353,7 +2361,7 @@ public class VariableNeighborhoodSearch {
*/
private int selectMachineByLoad(List<Integer> availableMachineSeqs, List<MachineOption> machineOptions, Chromosome chromosome) {
// 计算当前各设备的负载(利用率)
Map<Long, Double> machineUtilization = calculateMachineUtilization(chromosome);
Map<Long, Double> machineUtilization = calculateMachineUtilization(chromosome,true);
// 构建可用机器列表,按负载从低到高排序
List<MachineOptionWithUtilization> availableMachines = new ArrayList<>();
......
......@@ -190,7 +190,7 @@ public class PlanResultService {
try {
ScheduleParams param = InitScheduleParams();
param.setBaseTime(LocalDateTime.of(2026, 5, 20, 0, 0, 0));
// param.setBaseTime(LocalDateTime.of(2026, 5, 20, 0, 0, 0));
this.baseTime=param.getBaseTime();
// 策略读取入口:优先使用前端传入的 userId;没传时用 sceneId 查场景创建人。
Long effectiveUserId = scheduleStrategyService.resolveScheduleUserId(SceneId, userId);
......
......@@ -42,8 +42,8 @@ public class PlanResultServiceTest {
// nsgaiiUtils.Test();
// planResultService.execute2("64E64F6B68094AF38CEDC418630C3CC2");//2000
planResultService.execute2("E1448B3C9C8743DEAB39708F2CFE348A");//倒排bomces
// planResultService.execute2("197083D0D26A449EB179AC103C753FD3");
// planResultService.execute2("E1448B3C9C8743DEAB39708F2CFE348A");//倒排bomces
planResultService.execute2("197083D0D26A449EB179AC103C753FD3");
// planResultService.execute2("9FEDFD92BB6A4675BF9B1CC64505D1AB");
// planResultService.execute2("15210B13B88A453F8B84AAC7F16C7541");//2000
......
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