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
ff663b04
Commit
ff663b04
authored
Jun 11, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
19477178
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
15 deletions
+21
-15
HillClimbing.java
src/main/java/com/aps/service/Algorithm/HillClimbing.java
+4
-3
SimulatedAnnealing.java
...in/java/com/aps/service/Algorithm/SimulatedAnnealing.java
+5
-5
TabuSearch.java
src/main/java/com/aps/service/Algorithm/TabuSearch.java
+6
-4
VariableNeighborhoodSearch.java
...com/aps/service/Algorithm/VariableNeighborhoodSearch.java
+3
-3
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+3
-0
No files found.
src/main/java/com/aps/service/Algorithm/HillClimbing.java
View file @
ff663b04
...
@@ -74,9 +74,9 @@ public class HillClimbing {
...
@@ -74,9 +74,9 @@ public class HillClimbing {
*/
*/
public
Chromosome
searchAll
(
Chromosome
chromosome
,
List
<
Machine
>
machines
,
GeneticDecoder
decoder
)
{
public
Chromosome
searchAll
(
Chromosome
chromosome
,
List
<
Machine
>
machines
,
GeneticDecoder
decoder
)
{
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
// 构建位置索引映射:groupId_sequence -> position
// 构建位置索引映射:groupId_sequence -> position
Map
<
String
,
Integer
>
positionIndex
=
buildPositionIndex
(
current
);
Map
<
String
,
Integer
>
positionIndex
=
buildPositionIndex
(
current
);
...
@@ -88,6 +88,7 @@ public class HillClimbing {
...
@@ -88,6 +88,7 @@ public class HillClimbing {
Map
<
Integer
,
Entry
>
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
Map
<
Integer
,
Entry
>
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
boolean
improved
=
false
;
boolean
improved
=
false
;
for
(
Double
priority
:
sortedPriorities
)
{
for
(
Double
priority
:
sortedPriorities
)
{
decoder
.
DelOrder
(
current
);
List
<
Entry
>
priorityOps
=
priorityGroups
.
get
(
priority
);
List
<
Entry
>
priorityOps
=
priorityGroups
.
get
(
priority
);
if
(
priorityOps
.
isEmpty
())
{
if
(
priorityOps
.
isEmpty
())
{
continue
;
continue
;
...
@@ -238,7 +239,7 @@ public class HillClimbing {
...
@@ -238,7 +239,7 @@ public class HillClimbing {
current
=
ProductionDeepCopyUtil
.
deepCopy
(
best
,
Chromosome
.
class
);
current
=
ProductionDeepCopyUtil
.
deepCopy
(
best
,
Chromosome
.
class
);
positionIndex
=
buildPositionIndex
(
current
);
positionIndex
=
buildPositionIndex
(
current
);
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
decoder
.
DelOrder
(
current
);
//
decoder.DelOrder(current);
}
}
}
}
}
}
...
...
src/main/java/com/aps/service/Algorithm/SimulatedAnnealing.java
View file @
ff663b04
...
@@ -100,7 +100,7 @@ public class SimulatedAnnealing {
...
@@ -100,7 +100,7 @@ public class SimulatedAnnealing {
log
(
"模拟退火+爬山法 - 开始执行"
,
true
);
log
(
"模拟退火+爬山法 - 开始执行"
,
true
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
writeKpi
(
best
);
writeKpi
(
best
);
...
@@ -134,7 +134,7 @@ public class SimulatedAnnealing {
...
@@ -134,7 +134,7 @@ public class SimulatedAnnealing {
for
(
int
i
=
0
;
i
<
maxIterations
;
i
++)
{
for
(
int
i
=
0
;
i
<
maxIterations
;
i
++)
{
totalIterations
=
i
+
1
;
totalIterations
=
i
+
1
;
boolean
improved
=
false
;
boolean
improved
=
false
;
decoder
.
DelOrder
(
current
);
// 1. 使用智能策略生成邻域解(找瓶颈工序/设备)
// 1. 使用智能策略生成邻域解(找瓶颈工序/设备)
Chromosome
neighbor
=
vns
.
generateNeighbor
(
current
);
Chromosome
neighbor
=
vns
.
generateNeighbor
(
current
);
...
@@ -168,7 +168,7 @@ public class SimulatedAnnealing {
...
@@ -168,7 +168,7 @@ public class SimulatedAnnealing {
log
(
String
.
format
(
"模拟退火+爬山法 - 迭代%d:找到更优解(微小),fitness=%.4f"
,
totalIterations
,
best
.
getFitness
()),
true
);
log
(
String
.
format
(
"模拟退火+爬山法 - 迭代%d:找到更优解(微小),fitness=%.4f"
,
totalIterations
,
best
.
getFitness
()),
true
);
}
}
}
}
decoder
.
DelOrder
(
current
);
}
}
if
(!
improved
)
{
if
(!
improved
)
{
...
@@ -243,7 +243,6 @@ public class SimulatedAnnealing {
...
@@ -243,7 +243,6 @@ public class SimulatedAnnealing {
decode
(
decoder
,
current
,
machines
);
decode
(
decoder
,
current
,
machines
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
writeKpi
(
best
);
writeKpi
(
best
);
// 初始化解码
// 初始化解码
...
@@ -279,6 +278,7 @@ public class SimulatedAnnealing {
...
@@ -279,6 +278,7 @@ public class SimulatedAnnealing {
totalIterations
=
i
+
1
;
totalIterations
=
i
+
1
;
boolean
improved
=
false
;
boolean
improved
=
false
;
log
(
String
.
format
(
"模拟退火 - 迭代%d:"
,
totalIterations
));
log
(
String
.
format
(
"模拟退火 - 迭代%d:"
,
totalIterations
));
decoder
.
DelOrder
(
current
);
// 1. 使用智能策略生成邻域解(找瓶颈工序/设备)
// 1. 使用智能策略生成邻域解(找瓶颈工序/设备)
Chromosome
neighbor
=
vns
.
generateNeighbor
(
current
);
Chromosome
neighbor
=
vns
.
generateNeighbor
(
current
);
...
@@ -320,7 +320,7 @@ public class SimulatedAnnealing {
...
@@ -320,7 +320,7 @@ public class SimulatedAnnealing {
log
(
String
.
format
(
"模拟退火 - 迭代%d:找到更优解(微小),fitness=%.4f"
,
totalIterations
,
best
.
getFitness
()));
log
(
String
.
format
(
"模拟退火 - 迭代%d:找到更优解(微小),fitness=%.4f"
,
totalIterations
,
best
.
getFitness
()));
}
}
}
}
decoder
.
DelOrder
(
current
);
//
decoder.DelOrder(current);
}
}
if
(!
improved
)
{
if
(!
improved
)
{
...
...
src/main/java/com/aps/service/Algorithm/TabuSearch.java
View file @
ff663b04
...
@@ -9,6 +9,7 @@ import com.aps.entity.basic.*;
...
@@ -9,6 +9,7 @@ import com.aps.entity.basic.*;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.stream.Collectors
;
/**
/**
* 禁忌搜索算法
* 禁忌搜索算法
...
@@ -66,7 +67,7 @@ public class TabuSearch {
...
@@ -66,7 +67,7 @@ public class TabuSearch {
log
(
"禁忌搜索 - 开始执行"
,
true
);
log
(
"禁忌搜索 - 开始执行"
,
true
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
//
decoder.DelOrder(current);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
this
.
bestFitness
=
best
.
getFitnessLevel
().
clone
();
this
.
bestFitness
=
best
.
getFitnessLevel
().
clone
();
writeKpi
(
best
);
writeKpi
(
best
);
...
@@ -79,7 +80,7 @@ public class TabuSearch {
...
@@ -79,7 +80,7 @@ public class TabuSearch {
int
significantImproveCount
=
0
;
int
significantImproveCount
=
0
;
int
noImprovementCount
=
0
;
int
noImprovementCount
=
0
;
int
maxNoImprovement
=
5
;
// 优化:5次无改进则停止
int
maxNoImprovement
=
5
;
// 优化:5次无改进则停止
int
maxIterations
=
Math
.
min
(
cachedAllOperations
.
size
(),
20
);
// 优化:最多20次迭代
int
maxIterations
=
1
;
//
Math.min(cachedAllOperations.size(), 20); // 优化:最多20次迭代
// 改进率监控
// 改进率监控
int
stagnantWindow
=
10
;
int
stagnantWindow
=
10
;
...
@@ -94,7 +95,7 @@ public class TabuSearch {
...
@@ -94,7 +95,7 @@ public class TabuSearch {
for
(
int
i
=
0
;
i
<
maxIterations
;
i
++)
{
for
(
int
i
=
0
;
i
<
maxIterations
;
i
++)
{
iterations
++;
iterations
++;
decoder
.
DelOrder
(
current
);
// 使用 VNS 生成邻域解(成功率排序后的策略)
// 使用 VNS 生成邻域解(成功率排序后的策略)
Chromosome
neighbor
=
vns
.
generateNeighbor
(
current
);
Chromosome
neighbor
=
vns
.
generateNeighbor
(
current
);
...
@@ -180,8 +181,9 @@ public class TabuSearch {
...
@@ -180,8 +181,9 @@ public class TabuSearch {
}
else
{
}
else
{
// 没有改进
// 没有改进
noImprovementCount
++;
noImprovementCount
++;
}
}
decoder
.
DelOrder
(
current
);
}
else
{
}
else
{
// 不接受,无改进计数+1
// 不接受,无改进计数+1
noImprovementCount
++;
noImprovementCount
++;
...
...
src/main/java/com/aps/service/Algorithm/VariableNeighborhoodSearch.java
View file @
ff663b04
...
@@ -317,7 +317,7 @@ public class VariableNeighborhoodSearch {
...
@@ -317,7 +317,7 @@ public class VariableNeighborhoodSearch {
// 深拷贝当前染色体
// 深拷贝当前染色体
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
geneticOperations
.
DelOrder
(
current
);
//
geneticOperations.DelOrder(current);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
writeKpi
(
best
);
writeKpi
(
best
);
...
@@ -339,7 +339,7 @@ public class VariableNeighborhoodSearch {
...
@@ -339,7 +339,7 @@ public class VariableNeighborhoodSearch {
while
(
noImproveRoundCount
<
maxNoImproveRounds
)
{
while
(
noImproveRoundCount
<
maxNoImproveRounds
)
{
totalRounds
++;
totalRounds
++;
log
(
"变邻域搜索 - 轮次"
+
totalRounds
+
", K==="
+
k
);
log
(
"变邻域搜索 - 轮次"
+
totalRounds
+
", K==="
+
k
);
geneticOperations
.
DelOrder
(
current
);
NeighborhoodStructure
neighborhood
=
neighborhoods
.
get
(
k
);
NeighborhoodStructure
neighborhood
=
neighborhoods
.
get
(
k
);
// 找到对应的统计对象
// 找到对应的统计对象
...
@@ -399,7 +399,7 @@ public class VariableNeighborhoodSearch {
...
@@ -399,7 +399,7 @@ public class VariableNeighborhoodSearch {
break
;
break
;
}
}
}
}
geneticOperations
.
DelOrder
(
current
);
}
else
{
}
else
{
k
++;
// 尝试下一个邻域
k
++;
// 尝试下一个邻域
// 检查是否完成一轮
// 检查是否完成一轮
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
ff663b04
...
@@ -285,6 +285,9 @@ public class PlanResultService {
...
@@ -285,6 +285,9 @@ public class PlanResultService {
KpiCalculator
kpiCalculator
=
new
KpiCalculator
(
chromosome
);
KpiCalculator
kpiCalculator
=
new
KpiCalculator
(
chromosome
);
kpiCalculator
.
calculatekpi
();
kpiCalculator
.
calculatekpi
();
// 添加锁定期工单到调度结果中
// 添加锁定期工单到调度结果中
// 这里会从 Dispatch 表加载锁定期工单,并添加到 chromosome.result 中
// 这里会从 Dispatch 表加载锁定期工单,并添加到 chromosome.result 中
lockedOrderProcessorService
.
addLockedOrdersToResult
(
chromosome
);
lockedOrderProcessorService
.
addLockedOrdersToResult
(
chromosome
);
...
...
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