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
fa7cf28d
Commit
fa7cf28d
authored
Apr 20, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/tl'
parents
a46c938c
2e356235
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
9 deletions
+68
-9
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+45
-0
HillClimbing.java
src/main/java/com/aps/service/Algorithm/HillClimbing.java
+7
-0
HybridAlgorithm.java
src/main/java/com/aps/service/Algorithm/HybridAlgorithm.java
+5
-3
SimulatedAnnealing.java
...in/java/com/aps/service/Algorithm/SimulatedAnnealing.java
+4
-0
TabuSearch.java
src/main/java/com/aps/service/Algorithm/TabuSearch.java
+2
-0
VariableNeighborhoodSearch.java
...com/aps/service/Algorithm/VariableNeighborhoodSearch.java
+4
-2
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+1
-4
No files found.
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
fa7cf28d
...
...
@@ -2756,4 +2756,49 @@ public class GeneticDecoder {
// return machineStr + "_" + operationStr;
}
public
void
DelOrder
(
Chromosome
chromosome
)
{
List
<
Entry
>
allOperations
=
chromosome
.
getAllOperations
();
List
<
GlobalOperationInfo
>
globalOpList
=
chromosome
.
getGlobalOpList
();
if
(
chromosome
.
getOrders
()==
null
||
chromosome
.
getOrders
().
size
()==
0
)
return
;
List
<
Order
>
orders
=
chromosome
.
getOrders
();
List
<
Integer
>
OperationSequencing
=
chromosome
.
getOperationSequencing
();
List
<
Integer
>
newoorderids
=
orders
.
stream
()
.
filter
(
t
->
t
.
isNewSfCreate
())
.
map
(
Order:
:
getId
)
.
sorted
(
Comparator
.
reverseOrder
())
.
collect
(
Collectors
.
toList
());
if
(
newoorderids
!=
null
&&
newoorderids
.
size
()>
0
)
{
for
(
Integer
id
:
newoorderids
)
{
List
<
Entry
>
sourceOps
=
allOperations
.
stream
()
.
filter
(
o
->
o
.
getGroupId
()==
id
)
.
sorted
(
Comparator
.
comparing
(
Entry:
:
getSequence
))
.
collect
(
Collectors
.
toList
());
for
(
Entry
entry
:
sourceOps
)
{
OptionalInt
index1
=
IntStream
.
range
(
0
,
globalOpList
.
size
())
.
filter
(
h
->
entry
.
getId
()==
globalOpList
.
get
(
h
).
getOp
().
getId
())
.
findFirst
();
globalOpList
.
remove
((
int
)
index1
.
orElse
(
0
));
chromosome
.
getMachineSelection
().
remove
((
int
)
index1
.
orElse
(
0
));
}
chromosome
.
getOperatRel
().
remove
(
id
-
1
);
}
allOperations
.
removeIf
(
t
->
newoorderids
.
contains
(
t
.
getGroupId
()));
OperationSequencing
.
removeIf
(
t
->
newoorderids
.
contains
(
t
));
AtomicInteger
globalOpId
=
new
AtomicInteger
(
0
);
globalOpList
.
forEach
(
t
->
{
t
.
setGlobalOpId
(
globalOpId
.
getAndIncrement
());
});
orders
.
removeIf
(
t
->
newoorderids
.
contains
(
t
.
getId
()));
}
}
}
src/main/java/com/aps/service/Algorithm/HillClimbing.java
View file @
fa7cf28d
...
...
@@ -74,6 +74,7 @@ public class HillClimbing {
*/
public
Chromosome
searchAll
(
Chromosome
chromosome
,
List
<
Machine
>
machines
,
GeneticDecoder
decoder
)
{
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
...
...
@@ -116,6 +117,7 @@ public class HillClimbing {
positionIndex
=
buildPositionIndex
(
current
);
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
MachinePositionIndex
=
buildEntryMachinePositionIndex
(
current
);
decoder
.
DelOrder
(
current
);
break
;
}
}
...
...
@@ -235,6 +237,7 @@ public class HillClimbing {
current
=
ProductionDeepCopyUtil
.
deepCopy
(
best
,
Chromosome
.
class
);
positionIndex
=
buildPositionIndex
(
current
);
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
decoder
.
DelOrder
(
current
);
}
}
}
...
...
@@ -243,6 +246,7 @@ public class HillClimbing {
public
Chromosome
search
(
Chromosome
chromosome
,
GeneticDecoder
decoder
,
List
<
Machine
>
machines
)
{
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
...
...
@@ -289,6 +293,7 @@ public class HillClimbing {
MachinePositionIndex
=
buildEntryMachinePositionIndex
(
current
);
break
;
}
decoder
.
DelOrder
(
current
);
}
}
if
(
improved
)
break
;
...
...
@@ -353,6 +358,7 @@ public class HillClimbing {
noImproveCount
=
0
;
positionIndex
=
buildPositionIndex
(
current
);
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
decoder
.
DelOrder
(
current
);
break
;
}
}
...
...
@@ -382,6 +388,7 @@ public class HillClimbing {
noImproveCount
=
0
;
positionIndex
=
buildPositionIndex
(
current
);
entryIndex
=
buildEntryIndex
(
current
,
entrys
);
decoder
.
DelOrder
(
current
);
break
;
}
}
...
...
src/main/java/com/aps/service/Algorithm/HybridAlgorithm.java
View file @
fa7cf28d
...
...
@@ -140,9 +140,11 @@ int opcount=allOperations.size();
// return getBestChromosome(population.get(0), param.getBaseTime(), starttime);
// 步骤2:对初始种群进行爬山法局部优化
if
(
opcount
<
100
)
{
Chromosome
best
=
population
.
get
(
0
);
geneticOps
.
DelOrder
(
best
);
FileHelper
.
writeLogFile
(
"爬山法局部优化-----------开始-------"
);
GeneticDecoder
hillClimbingDecoder
=
new
GeneticDecoder
(
_GlobalParam
,
param
.
getBaseTime
(),
machines
,
orders
,
materials
,
machineScheduler
,
materialRequirementService
,
sceneId
);
...
...
@@ -164,7 +166,7 @@ int opcount=allOperations.size();
if
(
opcount
<
800
)
{
Chromosome
best
=
population
.
get
(
0
);
geneticOps
.
DelOrder
(
best
);
FileHelper
.
writeLogFile
(
"模拟退火+爬山法优化-----------开始-------"
);
Chromosome
saHcOptimized
=
_simulatedAnnealing
.
searchWithHillClimbing
(
best
,
_vns
,
saDecoder1
,
machines
);
FileHelper
.
writeLogFile
(
"模拟退火+爬山法优化-----------结束-------"
);
...
...
@@ -173,7 +175,7 @@ int opcount=allOperations.size();
}
if
(
opcount
>=
800
)
{
Chromosome
best
=
population
.
get
(
0
);
geneticOps
.
DelOrder
(
best
);
best
=
_simulatedAnnealing
.
search
(
best
,
_tabuSearch
,
_vns
,
saDecoder1
,
machines
);
best
=
_vns
.
search
(
best
,
vnsDecoder1
,
machines
);
best
=
_tabuSearch
.
search
(
best
,
_vns
,
tabuDecoder1
,
machines
);
...
...
src/main/java/com/aps/service/Algorithm/SimulatedAnnealing.java
View file @
fa7cf28d
...
...
@@ -100,6 +100,7 @@ public class SimulatedAnnealing {
log
(
"模拟退火+爬山法 - 开始执行"
,
true
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
writeKpi
(
best
);
...
...
@@ -167,6 +168,7 @@ public class SimulatedAnnealing {
log
(
String
.
format
(
"模拟退火+爬山法 - 迭代%d:找到更优解(微小),fitness=%.4f"
,
totalIterations
,
best
.
getFitness
()),
true
);
}
}
decoder
.
DelOrder
(
current
);
}
if
(!
improved
)
{
...
...
@@ -238,6 +240,7 @@ public class SimulatedAnnealing {
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decode
(
decoder
,
current
,
machines
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
writeKpi
(
best
);
// 初始化解码
...
...
@@ -314,6 +317,7 @@ public class SimulatedAnnealing {
log
(
String
.
format
(
"模拟退火 - 迭代%d:找到更优解(微小),fitness=%.4f"
,
totalIterations
,
best
.
getFitness
()));
}
}
decoder
.
DelOrder
(
current
);
}
if
(!
improved
)
{
...
...
src/main/java/com/aps/service/Algorithm/TabuSearch.java
View file @
fa7cf28d
...
...
@@ -66,6 +66,7 @@ public class TabuSearch {
log
(
"禁忌搜索 - 开始执行"
,
true
);
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
decoder
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
this
.
bestFitness
=
best
.
getFitnessLevel
().
clone
();
writeKpi
(
best
);
...
...
@@ -180,6 +181,7 @@ public class TabuSearch {
// 没有改进
noImprovementCount
++;
}
decoder
.
DelOrder
(
current
);
}
else
{
// 不接受,无改进计数+1
noImprovementCount
++;
...
...
src/main/java/com/aps/service/Algorithm/VariableNeighborhoodSearch.java
View file @
fa7cf28d
...
...
@@ -299,9 +299,10 @@ public class VariableNeighborhoodSearch {
*/
public
Chromosome
search
(
Chromosome
chromosome
,
GeneticDecoder
decoder
,
List
<
Machine
>
machines
)
{
log
(
"变邻域搜索 - 开始执行"
,
true
);
geneticOperations
.
DelOrder
(
chromosome
);
// 深拷贝当前染色体
Chromosome
current
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
geneticOperations
.
DelOrder
(
current
);
Chromosome
best
=
ProductionDeepCopyUtil
.
deepCopy
(
chromosome
,
Chromosome
.
class
);
writeKpi
(
best
);
...
...
@@ -359,7 +360,7 @@ public class VariableNeighborhoodSearch {
boolean
success
=
isBetter
(
localBest
,
best
);
boolean
isSignificant
=
isSignificantImprovement
(
localBest
,
best
);
if
(
success
)
{
best
=
localBest
;
best
=
ProductionDeepCopyUtil
.
deepCopy
(
localBest
,
Chromosome
.
class
);
;
writeKpi
(
best
);
current
=
localBest
;
totalImprovements
++;
...
...
@@ -373,6 +374,7 @@ public class VariableNeighborhoodSearch {
// 微小改进也接受,但不重置计数,继续尝试
log
(
String
.
format
(
"变邻域搜索 - 邻域成功(微小): %s"
,
neighborhood
.
name
),
true
);
}
geneticOperations
.
DelOrder
(
current
);
}
else
{
k
++;
// 尝试下一个邻域
// 检查是否完成一轮
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
fa7cf28d
...
...
@@ -199,10 +199,7 @@ public class PlanResultService {
for
(
Machine
machine
:
machines
){
Long
machineId
=
machine
.
getId
();
if
(
machineId
==
2406
)
{
int
i
=
0
;
}
if
(
machineIds
.
get
(
machineId
)!=
null
&&
machineIds
.
get
(
machineId
)>
3600
*
24
*
200
)
{
int
day
=
(
int
)
(
machineIds
.
get
(
machineId
)
/
3600
/
24
)+
100
;
...
...
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