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
cf038922
Commit
cf038922
authored
Jun 04, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
倒排冲突
parent
ae460151
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
13 deletions
+77
-13
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+77
-13
No files found.
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
cf038922
...
@@ -800,19 +800,19 @@ if(groupId==7)
...
@@ -800,19 +800,19 @@ if(groupId==7)
machineOption
,
chromosome
,
machineIdMap
,
machineTasksCache
,
entryIndexById
,
machineOption
,
chromosome
,
machineIdMap
,
machineTasksCache
,
entryIndexById
,
scheduleIndexById
,
dueDateForOp
,
0
,
true
,
opIsJit
);
scheduleIndexById
,
dueDateForOp
,
0
,
true
,
opIsJit
);
if
(
operationResult
.
isForwardFallbackRequired
())
{
if
(
operationResult
.
isForwardFallbackRequired
())
{
// 倒排中任一道序因换型/日历约束放不下时,先撤回本订单已倒排结果,再整单正排。
// 倒排失败时只修复当前工序及其后道已排工序。
List
<
Integer
>
removeOp
=
clearOrderSchedulingForForwardFallback
(
chromosome
,
groupId
,
machineTasksCache
,
scheduleIndexById
);
// 例如倒排顺序 3->2->1,2 放不下时撤回 2、3,再按 2->3 放到各自设备最后任务之后。
List
<
Integer
>
removeOp
=
clearOrderSchedulingFromSequence
(
chromosome
,
groupId
,
opSequence
,
entrysBygroupId
,
machineTasksCache
,
scheduleIndexById
);
if
(
operationResult
.
getStartTime
()==
0
)
int
repairStartTime
=
operationResult
.
getStartTime
();
{
int
forwardEndTime
=
scheduleOrderForwardFallback
(
groupId
,
removeOp
,
repairStartTime
,
chromosome
,
entrysBygroupId
,
machineIdMap
,
machineTasksCache
,
removeOp
.
clear
();
}
int
forwardEndTime
=
scheduleOrderForwardFallback
(
groupId
,
removeOp
,
0
,
chromosome
,
entrysBygroupId
,
machineIdMap
,
machineTasksCache
,
entryIndexById
,
scheduleIndexById
,
opMachineKeyMap
);
entryIndexById
,
scheduleIndexById
,
opMachineKeyMap
);
orderProcessCounter
.
put
(
groupId
,
entrysBygroupId
.
get
(
groupId
).
size
()
);
orderProcessCounter
.
put
(
groupId
,
scheduledCount
+
1
);
orderLastEndTime
.
put
(
groupId
,
forwardEndTime
);
orderLastEndTime
.
put
(
groupId
,
forwardEndTime
);
forwardFallbackOrderIds
.
add
(
groupId
);
if
(
orderProcessCounter
.
get
(
groupId
)
>=
entrysBygroupId
.
get
(
groupId
).
size
())
{
forwardFallbackOrderIds
.
add
(
groupId
);
}
//如果是半成品
//如果是半成品
if
(
semiFinishedOrderIds
.
contains
(
groupId
))
{
if
(
semiFinishedOrderIds
.
contains
(
groupId
))
{
Set
<
Integer
>
fallbackFinishedIds
=
new
HashSet
<>();
Set
<
Integer
>
fallbackFinishedIds
=
new
HashSet
<>();
...
@@ -831,7 +831,7 @@ if(groupId==7)
...
@@ -831,7 +831,7 @@ if(groupId==7)
entrysBygroupId
,
orderProcessCounter
,
orderLastEndTime
,
entrysBygroupId
,
orderProcessCounter
,
orderLastEndTime
,
forwardFallbackOrderIds
,
orderSchedulingInfo
);
forwardFallbackOrderIds
,
orderSchedulingInfo
);
}
}
opCount
+=
entrysBygroupId
.
get
(
groupId
)
.
size
();
opCount
+=
removeOp
.
size
();
continue
;
continue
;
}
}
int
actualEndTime
=
operationResult
.
getEndTime
();
int
actualEndTime
=
operationResult
.
getEndTime
();
...
@@ -1363,9 +1363,12 @@ if(groupId==7)
...
@@ -1363,9 +1363,12 @@ if(groupId==7)
+
", sequence="
+
currentOp
.
getSequence
());
+
", sequence="
+
currentOp
.
getSequence
());
}
}
int
operationStartTime
=
calcForwardRepairStartTime
(
currentOp
,
machineOption
,
starttime
,
chromosome
,
machineIdMap
,
machineTasksCache
,
entryIndexById
,
scheduleIndexById
);
OperationScheduleResult
operationResult
=
processOperationSchedule
(
currentOp
,
machineOption
.
getMachineId
(),
OperationScheduleResult
operationResult
=
processOperationSchedule
(
currentOp
,
machineOption
.
getMachineId
(),
machineOption
.
getProcessingTime
(),
machineOption
,
chromosome
,
machineIdMap
,
machineOption
.
getProcessingTime
(),
machineOption
,
chromosome
,
machineIdMap
,
machineTasksCache
,
entryIndexById
,
scheduleIndexById
,
0
,
0
,
true
,
false
);
machineTasksCache
,
entryIndexById
,
scheduleIndexById
,
0
,
operationStartTime
,
true
,
false
);
if
(
operationResult
.
isForwardFallbackRequired
())
{
if
(
operationResult
.
isForwardFallbackRequired
())
{
throw
new
IllegalStateException
(
"正排兜底过程中不应再次触发正排兜底,groupId="
+
groupId
throw
new
IllegalStateException
(
"正排兜底过程中不应再次触发正排兜底,groupId="
+
groupId
+
", operationId="
+
currentOp
.
getId
());
+
", operationId="
+
currentOp
.
getId
());
...
@@ -1376,8 +1379,32 @@ if(groupId==7)
...
@@ -1376,8 +1379,32 @@ if(groupId==7)
}
}
/**
/**
*
整单正排前先撤回本订单已经写入的倒排结果,同时归还机台可用时
间。
*
局部正排修复的起点:不能早于外部指定时间、前序完成时间,也不能插到本设备已有任务中
间。
*/
*/
private
int
calcForwardRepairStartTime
(
Entry
currentOp
,
OpMachine
machineOption
,
int
starttime
,
Chromosome
chromosome
,
Map
<
Long
,
Machine
>
machineIdMap
,
Map
<
Long
,
CopyOnWriteArrayList
<
GAScheduleResult
>>
machineTasksCache
,
Map
<
Integer
,
Entry
>
entryIndexById
,
Map
<
Integer
,
GAScheduleResult
>
scheduleIndexById
)
{
int
earliestStartTime
=
starttime
;
Machine
targetMachine
=
machineIdMap
.
get
(
machineOption
.
getMachineId
());
if
(
targetMachine
!=
null
&&
!
currentOp
.
getPrevEntryIds
().
isEmpty
())
{
earliestStartTime
=
CalPrevtime
(
earliestStartTime
,
currentOp
,
chromosome
,
machineOption
.
getProcessingTime
(),
targetMachine
,
entryIndexById
,
scheduleIndexById
);
}
CopyOnWriteArrayList
<
GAScheduleResult
>
machineTasks
=
getMachineTasks
(
machineOption
.
getMachineId
(),
chromosome
,
machineTasksCache
);
GAScheduleResult
lastMachineTask
=
getLastMachineTask
(
machineTasks
);
if
(
lastMachineTask
!=
null
)
{
earliestStartTime
=
Math
.
max
(
earliestStartTime
,
lastMachineTask
.
getEndTime
());
}
return
earliestStartTime
;
}
private
List
<
Integer
>
clearOrderSchedulingForForwardFallback
(
Chromosome
chromosome
,
private
List
<
Integer
>
clearOrderSchedulingForForwardFallback
(
Chromosome
chromosome
,
int
groupId
,
int
groupId
,
Map
<
Long
,
CopyOnWriteArrayList
<
GAScheduleResult
>>
machineTasksCache
,
Map
<
Long
,
CopyOnWriteArrayList
<
GAScheduleResult
>>
machineTasksCache
,
...
@@ -1409,6 +1436,43 @@ if(groupId==7)
...
@@ -1409,6 +1436,43 @@ if(groupId==7)
/**
* 倒排局部失败时,只撤回当前失败工序及其后道已经写入的排程结果。
* 这样 2 失败只会重排 2、3,1 失败才会重排 1、2、3。
*/
private
List
<
Integer
>
clearOrderSchedulingFromSequence
(
Chromosome
chromosome
,
int
groupId
,
int
failedSequence
,
Map
<
Integer
,
List
<
Entry
>>
entrysBygroupId
,
Map
<
Long
,
CopyOnWriteArrayList
<
GAScheduleResult
>>
machineTasksCache
,
Map
<
Integer
,
GAScheduleResult
>
scheduleIndexById
)
{
Set
<
Integer
>
repairOperationIds
=
entrysBygroupId
.
getOrDefault
(
groupId
,
Collections
.
emptyList
()).
stream
()
.
filter
(
op
->
op
.
getSequence
()
>=
failedSequence
)
.
map
(
Entry:
:
getId
)
.
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
));
List
<
GAScheduleResult
>
resultsToRemove
=
chromosome
.
getResult
().
stream
()
.
filter
(
result
->
repairOperationIds
.
contains
(
result
.
getOperationId
()))
.
collect
(
Collectors
.
toList
());
for
(
GAScheduleResult
result
:
resultsToRemove
)
{
Machine
machine
=
getMachineById
(
chromosome
,
result
.
getMachineId
());
if
(
machine
!=
null
)
{
AddMachineAvailable
(
machine
,
result
.
getGeneDetails
());
}
chromosome
.
getResult
().
remove
(
result
);
scheduleIndexById
.
remove
(
result
.
getOperationId
());
CopyOnWriteArrayList
<
GAScheduleResult
>
machineTasks
=
machineTasksCache
.
get
(
result
.
getMachineId
());
if
(
machineTasks
!=
null
)
{
machineTasks
.
removeIf
(
t
->
t
.
getOperationId
()
==
result
.
getOperationId
());
}
}
machineTasksCache
.
clear
();
return
new
ArrayList
<>(
repairOperationIds
);
}
private
int
processOperation
(
Entry
currentOp
,
Long
machineId
,
double
processTime
,
private
int
processOperation
(
Entry
currentOp
,
Long
machineId
,
double
processTime
,
OpMachine
machineOption
,
Chromosome
chromosome
,
OpMachine
machineOption
,
Chromosome
chromosome
,
Map
<
Long
,
Machine
>
machineIdMap
,
Map
<
Long
,
Machine
>
machineIdMap
,
...
...
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