Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HYH.APSJ
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
佟礼
HYH.APSJ
Commits
a94f7c82
Commit
a94f7c82
authored
Jun 17, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
ccd683c2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
24 deletions
+32
-24
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+9
-9
GeneticDecoderBom.java
...ain/java/com/aps/service/Algorithm/GeneticDecoderBom.java
+5
-5
VariableNeighborhoodSearch.java
...com/aps/service/Algorithm/VariableNeighborhoodSearch.java
+15
-7
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+1
-1
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+2
-2
No files found.
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
a94f7c82
...
@@ -504,7 +504,7 @@ public class GeneticDecoder {
...
@@ -504,7 +504,7 @@ public class GeneticDecoder {
public
void
serialDecode
(
Chromosome
chromosome
)
{
public
void
serialDecode
(
Chromosome
chromosome
)
{
long
decodeStart
=
System
.
nanoTime
();
long
decodeStart
=
System
.
nanoTime
();
chromosome
.
setScenarioID
(
sceneId
);
chromosome
.
setScenarioID
(
sceneId
);
boolean
isJit
=
true
;
//
_globalParam.isJit();
boolean
isJit
=
_globalParam
.
isJit
();
...
@@ -824,7 +824,7 @@ public class GeneticDecoder {
...
@@ -824,7 +824,7 @@ public class GeneticDecoder {
// 倒排失败时只修复当前工序及其后道已排工序。
// 倒排失败时只修复当前工序及其后道已排工序。
// 例如倒排顺序 3->2->1,2 放不下时撤回 2、3,再按 2->3 放到各自设备最后任务之后。
// 例如倒排顺序 3->2->1,2 放不下时撤回 2、3,再按 2->3 放到各自设备最后任务之后。
List
<
Integer
>
removeOp
=
clearOrderSchedulingFromSequence
(
chromosome
,
groupId
,
opSequence
,
List
<
Integer
>
removeOp
=
clearOrderSchedulingFromSequence
(
chromosome
,
groupId
,
opSequence
,
entrysBygroupId
,
machineTasksCache
,
scheduleIndexById
);
entrysBygroupId
,
machineTasksCache
,
scheduleIndexById
,
entryIndexById
);
int
repairStartTime
=
operationResult
.
getStartTime
();
int
repairStartTime
=
operationResult
.
getStartTime
();
int
forwardEndTime
=
scheduleOrderForwardFallback
(
groupId
,
removeOp
,
repairStartTime
,
chromosome
,
entrysBygroupId
,
machineIdMap
,
machineTasksCache
,
int
forwardEndTime
=
scheduleOrderForwardFallback
(
groupId
,
removeOp
,
repairStartTime
,
chromosome
,
entrysBygroupId
,
machineIdMap
,
machineTasksCache
,
...
@@ -910,9 +910,9 @@ public class GeneticDecoder {
...
@@ -910,9 +910,9 @@ public class GeneticDecoder {
Set
<
Integer
>
pendingFinishedIds
=
pendingReForwardMap
.
remove
(
groupId
);
Set
<
Integer
>
pendingFinishedIds
=
pendingReForwardMap
.
remove
(
groupId
);
if
(
pendingFinishedIds
!=
null
&&
!
pendingFinishedIds
.
isEmpty
())
{
if
(
pendingFinishedIds
!=
null
&&
!
pendingFinishedIds
.
isEmpty
())
{
int
semiEndTime
=
orderLastEndTime
.
get
(
groupId
);
int
semiEndTime
=
orderLastEndTime
.
get
(
groupId
);
FileHelper
.
writeLogFile
(
"[ReForward] 半成品"
+
groupId
//
FileHelper.writeLogFile("[ReForward] 半成品" + groupId
+
"全部排完(结束时间="
+
semiEndTime
+
"),重新正排关联成品"
//
+ "全部排完(结束时间=" + semiEndTime + "),重新正排关联成品"
+
pendingFinishedIds
);
//
+ pendingFinishedIds);
reForwardFinishedOrders
(
groupId
,
semiEndTime
,
pendingFinishedIds
,
reForwardFinishedOrders
(
groupId
,
semiEndTime
,
pendingFinishedIds
,
chromosome
,
machineTasksCache
,
scheduleIndexById
,
chromosome
,
machineTasksCache
,
scheduleIndexById
,
machineIdMap
,
entryIndexById
,
opMachineKeyMap
,
machineIdMap
,
entryIndexById
,
opMachineKeyMap
,
...
@@ -1525,7 +1525,7 @@ public class GeneticDecoder {
...
@@ -1525,7 +1525,7 @@ public class GeneticDecoder {
int
failedSequence
,
int
failedSequence
,
Map
<
Integer
,
List
<
Entry
>>
entrysBygroupId
,
Map
<
Integer
,
List
<
Entry
>>
entrysBygroupId
,
Map
<
Long
,
CopyOnWriteArrayList
<
GAScheduleResult
>>
machineTasksCache
,
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
()
Set
<
Integer
>
repairOperationIds
=
entrysBygroupId
.
getOrDefault
(
groupId
,
Collections
.
emptyList
()).
stream
()
.
filter
(
op
->
op
.
getSequence
()
>=
failedSequence
)
.
filter
(
op
->
op
.
getSequence
()
>=
failedSequence
)
.
map
(
Entry:
:
getId
)
.
map
(
Entry:
:
getId
)
...
@@ -1537,7 +1537,7 @@ public class GeneticDecoder {
...
@@ -1537,7 +1537,7 @@ public class GeneticDecoder {
for
(
GAScheduleResult
result
:
resultsToRemove
)
{
for
(
GAScheduleResult
result
:
resultsToRemove
)
{
Entry
op
=
entry
sBygroupId
.
get
(
result
.
getGroupId
())
.
get
(
result
.
getOperationId
());
Entry
op
=
entry
IndexById
.
get
(
result
.
getOperationId
());
Map
<
String
,
MaterialDeduction
>
deductions
=
readOperationStockDeductions
(
op
);
Map
<
String
,
MaterialDeduction
>
deductions
=
readOperationStockDeductions
(
op
);
...
@@ -3750,8 +3750,8 @@ if(geneDetails!=null&&geneDetails.size()>0)
...
@@ -3750,8 +3750,8 @@ if(geneDetails!=null&&geneDetails.size()>0)
forwardFallbackOrderIds
.
add
(
finishedId
);
forwardFallbackOrderIds
.
add
(
finishedId
);
orderSchedulingInfo
.
put
(
finishedId
,
orderSchedulingInfo
.
put
(
finishedId
,
new
AbstractMap
.
SimpleEntry
<>(
false
,
0
));
new
AbstractMap
.
SimpleEntry
<>(
false
,
0
));
FileHelper
.
writeLogFile
(
"[ReForward] 半成品"
+
semiOrderId
//
FileHelper.writeLogFile("[ReForward] 半成品" + semiOrderId
+
"倒排早于基准时间,成品"
+
finishedId
+
"重新正排,结束时间="
+
forwardEndTime
);
//
+ "倒排早于基准时间,成品" + finishedId + "重新正排,结束时间=" + forwardEndTime);
}
}
reForwardFinishedOrderIds
.
clear
();
reForwardFinishedOrderIds
.
clear
();
}
}
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoderBom.java
View file @
a94f7c82
...
@@ -441,15 +441,15 @@ int start=Integer.MAX_VALUE;
...
@@ -441,15 +441,15 @@ int start=Integer.MAX_VALUE;
semiTotalTime
+=
ckeckLeadTime
;
semiTotalTime
+=
ckeckLeadTime
;
if
(
semiLatestEndTime
-
semiTotalTime
<
0
)
{
if
(
semiLatestEndTime
-
semiTotalTime
<
0
)
{
FileHelper
.
writeLogFile
(
"[HybridSemi] 半成品"
+
semiOrderId
+
//
FileHelper.writeLogFile("[HybridSemi] 半成品" + semiOrderId +
" 倒排开工<0,正排+成品"
+
finishedOrderId
+
"重排"
);
//
" 倒排开工<0,正排+成品" + finishedOrderId + "重排");
reForwardFinishedOrderIds
.
add
(
finishedOrderId
);
reForwardFinishedOrderIds
.
add
(
finishedOrderId
);
start
=
Math
.
min
(
start
,
-
1
);
start
=
Math
.
min
(
start
,
-
1
);
}
else
{
}
else
{
FileHelper
.
writeLogFile
(
"[HybridSemi] 半成品"
+
semiOrderId
+
//
FileHelper.writeLogFile("[HybridSemi] 半成品" + semiOrderId +
" 锚点="
+
semiLatestEndTime
+
" (成品"
+
finishedOrderId
+
//
" 锚点=" + semiLatestEndTime + " (成品" + finishedOrderId +
"开始="
+
finishedFirstResult
.
getStartTime
()
+
")"
);
//
"开始=" + finishedFirstResult.getStartTime() + ")");
start
=
Math
.
min
(
start
,
semiLatestEndTime
-
ckeckLeadTime
);
start
=
Math
.
min
(
start
,
semiLatestEndTime
-
ckeckLeadTime
);
}
}
...
...
src/main/java/com/aps/service/Algorithm/VariableNeighborhoodSearch.java
View file @
a94f7c82
...
@@ -631,7 +631,7 @@ public class VariableNeighborhoodSearch {
...
@@ -631,7 +631,7 @@ public class VariableNeighborhoodSearch {
private
Map
<
String
,
Object
>
findBottleneckMachineWithDetails
(
Chromosome
chromosome
)
{
private
Map
<
String
,
Object
>
findBottleneckMachineWithDetails
(
Chromosome
chromosome
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
GAScheduleResult
>
allResults
=
chromosome
.
getResult
().
stream
().
filter
(
t
->!
t
.
getCapacityTypeName
().
equals
(
"Infinite"
)).
collect
(
Collectors
.
toList
());
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
?
Map
<
Long
,
List
<
GAScheduleResult
>>
machineOps
=
allResults
!=
null
?
allResults
.
stream
().
collect
(
Collectors
.
groupingBy
(
GAScheduleResult:
:
getMachineId
))
:
allResults
.
stream
().
collect
(
Collectors
.
groupingBy
(
GAScheduleResult:
:
getMachineId
))
:
new
HashMap
<>();
new
HashMap
<>();
...
@@ -1121,7 +1121,7 @@ public class VariableNeighborhoodSearch {
...
@@ -1121,7 +1121,7 @@ public class VariableNeighborhoodSearch {
* 识别瓶颈设备(利用率最高的设备)
* 识别瓶颈设备(利用率最高的设备)
*/
*/
private
Long
findBottleneckMachine
(
Chromosome
chromosome
)
{
private
Long
findBottleneckMachine
(
Chromosome
chromosome
)
{
Map
<
Long
,
Double
>
utilization
=
calculateMachineUtilization
(
chromosome
);
Map
<
Long
,
Double
>
utilization
=
calculateMachineUtilization
(
chromosome
,
false
);
if
(
utilization
.
isEmpty
())
{
if
(
utilization
.
isEmpty
())
{
return
null
;
return
null
;
}
}
...
@@ -1147,11 +1147,19 @@ public class VariableNeighborhoodSearch {
...
@@ -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
<>();
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"
))
filter
(
t
->!
t
.
getCapacityTypeName
().
equals
(
"Infinite"
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
if
(
results
==
null
||
results
.
isEmpty
())
{
if
(
results
==
null
||
results
.
isEmpty
())
{
return
utilization
;
return
utilization
;
...
@@ -2353,7 +2361,7 @@ public class VariableNeighborhoodSearch {
...
@@ -2353,7 +2361,7 @@ public class VariableNeighborhoodSearch {
*/
*/
private
int
selectMachineByLoad
(
List
<
Integer
>
availableMachineSeqs
,
List
<
MachineOption
>
machineOptions
,
Chromosome
chromosome
)
{
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
<>();
List
<
MachineOptionWithUtilization
>
availableMachines
=
new
ArrayList
<>();
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
a94f7c82
...
@@ -190,7 +190,7 @@ public class PlanResultService {
...
@@ -190,7 +190,7 @@ public class PlanResultService {
try
{
try
{
ScheduleParams
param
=
InitScheduleParams
();
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
();
this
.
baseTime
=
param
.
getBaseTime
();
// 策略读取入口:优先使用前端传入的 userId;没传时用 sceneId 查场景创建人。
// 策略读取入口:优先使用前端传入的 userId;没传时用 sceneId 查场景创建人。
Long
effectiveUserId
=
scheduleStrategyService
.
resolveScheduleUserId
(
SceneId
,
userId
);
Long
effectiveUserId
=
scheduleStrategyService
.
resolveScheduleUserId
(
SceneId
,
userId
);
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
a94f7c82
...
@@ -42,8 +42,8 @@ public class PlanResultServiceTest {
...
@@ -42,8 +42,8 @@ public class PlanResultServiceTest {
// nsgaiiUtils.Test();
// nsgaiiUtils.Test();
// planResultService.execute2("64E64F6B68094AF38CEDC418630C3CC2");//2000
// planResultService.execute2("64E64F6B68094AF38CEDC418630C3CC2");//2000
planResultService
.
execute2
(
"E1448B3C9C8743DEAB39708F2CFE348A"
);
//倒排bomces
//
planResultService.execute2("E1448B3C9C8743DEAB39708F2CFE348A");//倒排bomces
//
planResultService.execute2("197083D0D26A449EB179AC103C753FD3");
planResultService
.
execute2
(
"197083D0D26A449EB179AC103C753FD3"
);
// planResultService.execute2("9FEDFD92BB6A4675BF9B1CC64505D1AB");
// planResultService.execute2("9FEDFD92BB6A4675BF9B1CC64505D1AB");
// planResultService.execute2("15210B13B88A453F8B84AAC7F16C7541");//2000
// planResultService.execute2("15210B13B88A453F8B84AAC7F16C7541");//2000
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment