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
c44201cc
Commit
c44201cc
authored
Dec 19, 2025
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
遗传算法-移动多工单,删除订单
parent
b779f0fc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
25 deletions
+42
-25
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+1
-1
GeneticOperations.java
...ain/java/com/aps/service/Algorithm/GeneticOperations.java
+1
-1
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+40
-23
No files found.
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
c44201cc
...
...
@@ -78,7 +78,7 @@ public class GeneticDecoder {
chromosome
.
setTotalChangeoverTime
(
cachedResult
.
getTotalChangeoverTime
());
chromosome
.
setMachineLoadStd
(
cachedResult
.
getMachineLoadStd
());
chromosome
.
setDelayTime
(
cachedResult
.
getDelayTime
());
chromosome
.
setResult
(
cachedResult
.
getResult
(
));
chromosome
.
setResult
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedResult
.
getResult
(),
GAScheduleResult
.
class
));
// Chromosome chromosomen= ProductionDeepCopyUtil.deepCopy(cachedResult);
return
chromosome
;
...
...
src/main/java/com/aps/service/Algorithm/GeneticOperations.java
View file @
c44201cc
...
...
@@ -63,7 +63,7 @@ public class GeneticOperations {
.
findFirst
()
// 处理空列表情况(避免NoSuchElementException)
.
orElse
(
null
);
selected
.
add
(
ProductionDeepCopyUtil
.
deepCopy
(
best
));
selected
.
add
(
ProductionDeepCopyUtil
.
deepCopy
(
best
,
Chromosome
.
class
));
}
return
selected
;
}
...
...
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
c44201cc
...
...
@@ -29,20 +29,20 @@ public class ScheduleOperationService {
/**
* 移动工序方法
* @param chromosome 染色体对象
* @param opId 工序ID
* @param opId
s
工序ID
* @param newStartTime 新开始时间
* @param newMachineId 新设备ID
*/
public
void
moveOperation
(
Chromosome
chromosome
,
List
<
Integer
>
opIds
,
int
newStartTime
,
Long
newMachineId
,
GlobalParam
globalParam
)
{
List
<
Entry
>
allOperations
=
chromosome
.
getAllOperations
();
int
newStartTime1
=
newStartTime
;
Map
<
Integer
,
Integer
>
opTimeMap
=
chromosome
.
getResult
().
stream
()
.
collect
(
Collectors
.
toMap
(
GAScheduleResult:
:
getOperationId
,
r
->
r
.
getStartTime
()
));
Integer
newMachineId1
=
newMachineId
.
intValue
();
for
(
Integer
opId:
opIds
)
{
...
...
@@ -57,6 +57,7 @@ public class ScheduleOperationService {
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Operation not found: "
+
opId
));
if
(
newMachineId1
!=
0
)
{
int
machineOptionIndex
=
targetOp
.
getMachineOptions
().
stream
()
.
map
(
MachineOption:
:
getMachineId
)
.
collect
(
Collectors
.
toList
())
...
...
@@ -66,9 +67,6 @@ public class ScheduleOperationService {
throw
new
NoSuchElementException
(
"Machine not found: "
+
newMachineId
);
}
// 设置约束
targetResult
.
setDesignatedStartTime
(
newStartTime
);
targetResult
.
setForcedMachineId
(
newMachineId
);
// 更新设备选择序列
int
globalOpIndex
=
chromosome
.
getGlobalOpList
().
stream
()
...
...
@@ -79,6 +77,14 @@ public class ScheduleOperationService {
chromosome
.
getMachineSelection
().
set
(
globalOpIndex
,
machineOptionIndex
);
targetResult
.
setForcedMachineId
(
newMachineId
);
}
else
{
newMachineId1
=(
int
)
targetResult
.
getMachineId
();
}
// 设置约束
targetResult
.
setDesignatedStartTime
(
newStartTime
);
if
(
targetOp
.
getSequence
()==
1
)
{
opTimeMap
.
put
(
opId
,
newStartTime
);
}
else
{
...
...
@@ -98,8 +104,19 @@ public class ScheduleOperationService {
opTimeMap
.
put
(
opId
,
targetResult1
.
getStartTime
()+
1
);
}
}
newStartTime
=
newStartTime
+
(
int
)
targetResult
.
getProcessingTime
()
;
newStartTime
=
newStartTime
+
1
;
}
Long
newMachineId2
=
newMachineId1
.
longValue
();
GAScheduleResult
FirstMachineResult
=
chromosome
.
getResult
().
stream
()
.
filter
(
r
->
r
.
getMachineId
()
==
newMachineId2
&&
r
.
getStartTime
()
>=
newStartTime1
)
.
findFirst
()
.
orElse
(
null
);
if
(
FirstMachineResult
!=
null
)
{
opTimeMap
.
put
(
FirstMachineResult
.
getOperationId
(),
newStartTime
);
}
// 生成新的工序顺序
...
...
@@ -238,7 +255,7 @@ public class ScheduleOperationService {
}
}
else
{
//不存在创建新的
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
targetOp
);
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
targetOp
,
Entry
.
class
);
newOp
.
setId
(
nodeInfo
.
getGlobalSerial
());
newOp
.
setSequence
(
nodeInfo
.
getGroupSerial
());
newOp
.
setExecId
(
nodeInfo
.
getOriginalId
());
...
...
@@ -320,7 +337,7 @@ public class ScheduleOperationService {
List
<
String
>
newChildIdList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
splitCounts
.
length
;
i
++)
{
maxorderId
++;
Order
neworder
=
ProductionDeepCopyUtil
.
deepCopy
(
order
);
Order
neworder
=
ProductionDeepCopyUtil
.
deepCopy
(
order
,
Order
.
class
);
neworder
.
setOrderId
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
if
(
splitCounts
[
0
]!=
0
&&
i
==
1
)
{
// 数组第一个是0,为复制
order
.
setQuantity
(
splitCounts
[
0
]);
...
...
@@ -335,7 +352,7 @@ public class ScheduleOperationService {
}
String
newId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
entry
);
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
entry
,
Entry
.
class
);
newOp
.
setExecId
(
newId
);
newOp
.
setOrderId
(
neworder
.
getOrderId
());
newOp
.
setGroupId
(
maxorderId
);
...
...
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