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
8231751e
Commit
8231751e
authored
Apr 16, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物料配套
parent
40085732
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
815 additions
and
126 deletions
+815
-126
Chromosome.java
src/main/java/com/aps/entity/Algorithm/Chromosome.java
+1
-1
ObjectiveWeights.java
src/main/java/com/aps/entity/Algorithm/ObjectiveWeights.java
+3
-3
Entry.java
src/main/java/com/aps/entity/basic/Entry.java
+4
-0
GlobalParam.java
src/main/java/com/aps/entity/basic/GlobalParam.java
+23
-6
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+342
-49
HybridAlgorithm.java
src/main/java/com/aps/service/Algorithm/HybridAlgorithm.java
+3
-0
MaterialRequirementService.java
...com/aps/service/Algorithm/MaterialRequirementService.java
+81
-32
NSGAIIUtils.java
src/main/java/com/aps/service/Algorithm/NSGAIIUtils.java
+3
-2
PostEditJitService.java
...in/java/com/aps/service/Algorithm/PostEditJitService.java
+299
-0
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+55
-33
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+1
-0
No files found.
src/main/java/com/aps/entity/Algorithm/Chromosome.java
View file @
8231751e
...
@@ -193,7 +193,7 @@ public class Chromosome {
...
@@ -193,7 +193,7 @@ public class Chromosome {
/// 交付期延迟时间
/// 交付期延迟时间
/// </summary>
/// </summary>
private
double
DelayTime
;
private
double
DelayTime
;
private
double
SemiJitSlack
;
private
String
ScenarioID
;
private
String
ScenarioID
;
...
...
src/main/java/com/aps/entity/Algorithm/ObjectiveWeights.java
View file @
8231751e
...
@@ -7,10 +7,10 @@ package com.aps.entity.Algorithm;
...
@@ -7,10 +7,10 @@ package com.aps.entity.Algorithm;
*/
*/
public
class
ObjectiveWeights
{
public
class
ObjectiveWeights
{
/**
/**
* 目标权重(默认值:[0.3, 0.2, 0.15, 0.2, 0.15])
* 目标权重(默认值:[0.3, 0.2, 0.15, 0.2, 0.15
, 0.01
])
* 对应:完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
* 对应:完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
、半成品JIT
*/
*/
private
double
[]
weights
=
new
double
[]
{
0.3
,
0.2
,
0.15
,
0.2
,
0.15
};
private
double
[]
weights
=
new
double
[]
{
0.3
,
0.2
,
0.15
,
0.2
,
0.15
,
0.01
};
/**
/**
* NSGA-II模式:true=纯帕累托(无视权重),false=加权帕累托
* NSGA-II模式:true=纯帕累托(无视权重),false=加权帕累托
...
...
src/main/java/com/aps/entity/basic/Entry.java
View file @
8231751e
...
@@ -160,4 +160,8 @@ private Long isInterrupt = 1l;
...
@@ -160,4 +160,8 @@ private Long isInterrupt = 1l;
@Schema
(
description
=
"指定开始时间"
)
@Schema
(
description
=
"指定开始时间"
)
@JsonInclude
(
JsonInclude
.
Include
.
ALWAYS
)
@JsonInclude
(
JsonInclude
.
Include
.
ALWAYS
)
private
LocalDateTime
designatedStartTime
;
private
LocalDateTime
designatedStartTime
;
private
LocalDateTime
jitPreferredStartTime
;
private
boolean
jitTemporary
=
false
;
}
}
src/main/java/com/aps/entity/basic/GlobalParam.java
View file @
8231751e
...
@@ -14,7 +14,6 @@ public class GlobalParam {
...
@@ -14,7 +14,6 @@ public class GlobalParam {
/// 是否可以打破优先级
/// 是否可以打破优先级
/// </summary>
/// </summary>
private
boolean
IsBreakPriority
=
false
;
private
boolean
IsBreakPriority
=
false
;
/// <summary>
/// <summary>
/// 是否多台设备
/// 是否多台设备
/// </summary>
/// </summary>
...
@@ -51,6 +50,16 @@ public class GlobalParam {
...
@@ -51,6 +50,16 @@ public class GlobalParam {
*/
*/
private
boolean
pureNSGAIIMode
=
true
;
private
boolean
pureNSGAIIMode
=
true
;
/**
* 半成品JIT缓冲时间(分钟)
*/
private
int
semiJitBufferMinutes
=
0
;
/**
* 物料/设备固定点求解最大迭代次数
*/
private
int
materialSolveMaxIterations
=
8
;
/// <summary>
/// <summary>
...
@@ -66,6 +75,7 @@ public class GlobalParam {
...
@@ -66,6 +75,7 @@ public class GlobalParam {
public
static
final
String
OBJECTIVE_SETUP_TIME
=
"setupTime"
;
// 总换型时间
public
static
final
String
OBJECTIVE_SETUP_TIME
=
"setupTime"
;
// 总换型时间
public
static
final
String
OBJECTIVE_MACHINE_LOAD
=
"machineLoad"
;
// 机器负载均衡
public
static
final
String
OBJECTIVE_MACHINE_LOAD
=
"machineLoad"
;
// 机器负载均衡
public
static
final
String
OBJECTIVE_TARDINESS
=
"tardiness"
;
// 延迟时间
public
static
final
String
OBJECTIVE_TARDINESS
=
"tardiness"
;
// 延迟时间
public
static
final
String
OBJECTIVE_SEMI_JIT
=
"semiJitSlack"
;
// 半成品提前完工惩罚
/// <summary>
/// <summary>
/// 构造函数,初始化默认值
/// 构造函数,初始化默认值
...
@@ -73,15 +83,22 @@ public class GlobalParam {
...
@@ -73,15 +83,22 @@ public class GlobalParam {
public
GlobalParam
()
{
public
GlobalParam
()
{
// 初始化默认目标值配置
// 初始化默认目标值配置
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
objectiveConfigs
.
add
(
new
ObjectiveConfig
(
OBJECTIVE_MAKESPAN
,
true
,
1
,
0.3
));
objectiveConfigs
.
add
(
createMinimizeObjectiveConfig
(
OBJECTIVE_MAKESPAN
,
1
,
0.3
));
objectiveConfigs
.
add
(
new
ObjectiveConfig
(
OBJECTIVE_FLOW_TIME
,
true
,
2
,
0.1
));
objectiveConfigs
.
add
(
createMinimizeObjectiveConfig
(
OBJECTIVE_FLOW_TIME
,
2
,
0.2
));
objectiveConfigs
.
add
(
new
ObjectiveConfig
(
OBJECTIVE_SETUP_TIME
,
true
,
2
,
0.1
));
objectiveConfigs
.
add
(
createMinimizeObjectiveConfig
(
OBJECTIVE_SETUP_TIME
,
2
,
0.15
));
objectiveConfigs
.
add
(
new
ObjectiveConfig
(
OBJECTIVE_MACHINE_LOAD
,
true
,
1
,
0.1
));
objectiveConfigs
.
add
(
createMinimizeObjectiveConfig
(
OBJECTIVE_MACHINE_LOAD
,
1
,
0.2
));
objectiveConfigs
.
add
(
new
ObjectiveConfig
(
OBJECTIVE_TARDINESS
,
true
,
1
,
0.6
));
objectiveConfigs
.
add
(
createMinimizeObjectiveConfig
(
OBJECTIVE_TARDINESS
,
1
,
0.15
));
objectiveConfigs
.
add
(
createMinimizeObjectiveConfig
(
OBJECTIVE_SEMI_JIT
,
2
,
0.01
));
objectiveConfigs
.
sort
(
Comparator
.
comparing
((
ObjectiveConfig
op
)
->
op
.
getLevel
()));
objectiveConfigs
.
sort
(
Comparator
.
comparing
((
ObjectiveConfig
op
)
->
op
.
getLevel
()));
}
}
private
ObjectiveConfig
createMinimizeObjectiveConfig
(
String
name
,
int
level
,
double
weight
)
{
ObjectiveConfig
config
=
new
ObjectiveConfig
(
name
,
true
,
level
,
weight
);
config
.
setMinimize
(
true
);
return
config
;
}
/// <summary>
/// <summary>
/// 获取目标值启用状态
/// 获取目标值启用状态
/// </summary>
/// </summary>
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
8231751e
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/Algorithm/HybridAlgorithm.java
View file @
8231751e
...
@@ -133,6 +133,9 @@ int opcount=allOperations.size();
...
@@ -133,6 +133,9 @@ int opcount=allOperations.size();
FileHelper
.
writeLogFile
(
"按Objectives去重-----------开始-------"
+
population
.
size
());
FileHelper
.
writeLogFile
(
"按Objectives去重-----------开始-------"
+
population
.
size
());
population
=
chromosomeDistinctByObjectives
(
population
);
population
=
chromosomeDistinctByObjectives
(
population
);
FileHelper
.
writeLogFile
(
"按Objectives去重-----------结束-------"
+
population
.
size
());
FileHelper
.
writeLogFile
(
"按Objectives去重-----------结束-------"
+
population
.
size
());
if
(
population
==
null
||
population
.
isEmpty
())
{
throw
new
RuntimeException
(
"初始种群为空,请检查 populationSize、种群初始化和解码结果"
);
}
// if(1==1)
// if(1==1)
// return getBestChromosome(population.get(0), param.getBaseTime(), starttime);
// return getBestChromosome(population.get(0), param.getBaseTime(), starttime);
// 步骤2:对初始种群进行爬山法局部优化
// 步骤2:对初始种群进行爬山法局部优化
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
8231751e
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/Algorithm/NSGAIIUtils.java
View file @
8231751e
...
@@ -19,7 +19,7 @@ public class NSGAIIUtils {
...
@@ -19,7 +19,7 @@ public class NSGAIIUtils {
private
int
taskCount
;
// 并行任务数(默认=CPU核心数)
private
int
taskCount
;
// 并行任务数(默认=CPU核心数)
private
GlobalParam
globalParam
;
// 全局参数配置
private
GlobalParam
globalParam
;
// 全局参数配置
// true 越小越好
// true 越小越好
private
boolean
[]
isMinimize
=
{
true
,
true
,
true
,
true
,
true
};
private
boolean
[]
isMinimize
=
{
true
,
true
,
true
,
true
,
true
,
true
};
...
@@ -627,7 +627,8 @@ public class NSGAIIUtils {
...
@@ -627,7 +627,8 @@ public class NSGAIIUtils {
for
(
int
i
=
0
;
i
<
kpisize
;
i
++)
{
for
(
int
i
=
0
;
i
<
kpisize
;
i
++)
{
final
int
idx
=
i
;
final
int
idx
=
i
;
if
(
isMinimize
[
i
])
boolean
minimize
=
i
>=
isMinimize
.
length
||
isMinimize
[
i
];
if
(
minimize
)
{
{
idealPoint
[
i
]
=
front
.
stream
().
mapToDouble
(
c
->
c
.
getObjectives
()[
idx
]).
min
().
orElse
(
0
);
idealPoint
[
i
]
=
front
.
stream
().
mapToDouble
(
c
->
c
.
getObjectives
()[
idx
]).
min
().
orElse
(
0
);
...
...
src/main/java/com/aps/service/Algorithm/PostEditJitService.java
0 → 100644
View file @
8231751e
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
8231751e
...
@@ -1851,42 +1851,23 @@ if(targetOp.getSequence()>1) {
...
@@ -1851,42 +1851,23 @@ if(targetOp.getSequence()>1) {
*/
*/
public
void
redecode
(
Chromosome
chromosome
,
LocalDateTime
baseTime
,
GlobalParam
globalParam
)
public
void
redecode
(
Chromosome
chromosome
,
LocalDateTime
baseTime
,
GlobalParam
globalParam
)
{
{
List
<
Material
>
baseMaterialsSnapshot
=
resolveDecodeMaterials
(
chromosome
);
List
<
Material
>
UseMaterials
=
materialRequirementService
.
GetMaterials
(
chromosome
.
getScenarioID
());
chromosome
.
setMaterials
(
new
ArrayList
<>());
if
(
UseMaterials
==
null
)
{
if
(
chromosome
.
getMaterialIds
()
!=
null
&&
chromosome
.
getMaterialIds
().
size
()
>
0
)
{
List
<
Material
>
Materials
=
planResultService
.
InitMaterial
();
UseMaterials
=
Materials
.
stream
()
.
filter
(
t
->
chromosome
.
getMaterialIds
()
.
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
chromosome
.
setMaterials
(
UseMaterials
);
materialRequirementService
.
SetMaterials
(
chromosome
.
getScenarioID
(),
UseMaterials
);
}
}
else
{
chromosome
.
setMaterials
(
UseMaterials
);
}
DelOrder
(
chromosome
);
MachineSchedulerService
machineScheduler
=
new
MachineSchedulerService
(
baseTime
);
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getInitMachines
(),
Machine
.
class
)
);
GeneticDecoder
decoder
=
new
GeneticDecoder
(
globalParam
,
baseTime
,
chromosome
.
getMachines
(),
chromosome
.
getOrders
(),
null
,
machineScheduler
,
materialRequirementService
,
chromosome
.
getScenarioID
());
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getResult
(),
GAScheduleResult
.
class
));
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getResult
(),
GAScheduleResult
.
class
));
chromosome
.
getResult
().
clear
();
GeneticDecoder
decoder
=
prepareDecodePass
(
chromosome
,
baseTime
,
globalParam
,
baseMaterialsSnapshot
,
true
);
CopyOnWriteArrayList
<
GAScheduleResult
>
Resultlock
=
chromosome
.
getResult
().
stream
()
.
filter
(
o
->
o
.
isIsLocked
()
==
true
)
.
collect
(
Collectors
.
toCollection
(
CopyOnWriteArrayList:
:
new
));
chromosome
.
setResult
(
ProductionDeepCopyUtil
.
deepCopyList
(
Resultlock
,
GAScheduleResult
.
class
));
decoder
.
decode
(
chromosome
,
false
);
decoder
.
decode
(
chromosome
,
false
);
PostEditJitService
postEditJitService
=
new
PostEditJitService
();
try
{
if
(
postEditJitService
.
applyPostEditJitBias
(
chromosome
,
globalParam
))
{
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getResult
(),
GAScheduleResult
.
class
));
decoder
=
prepareDecodePass
(
chromosome
,
baseTime
,
globalParam
,
baseMaterialsSnapshot
,
false
);
decoder
.
decode
(
chromosome
,
false
,
false
);
}
}
finally
{
postEditJitService
.
clearTemporaryJitBias
(
chromosome
);
}
KpiCalculator
kpiCalculator
=
new
KpiCalculator
(
chromosome
);
KpiCalculator
kpiCalculator
=
new
KpiCalculator
(
chromosome
);
kpiCalculator
.
calculatekpi
();
kpiCalculator
.
calculatekpi
();
...
@@ -1907,6 +1888,47 @@ if(targetOp.getSequence()>1) {
...
@@ -1907,6 +1888,47 @@ if(targetOp.getSequence()>1) {
}
}
private
GeneticDecoder
prepareDecodePass
(
Chromosome
chromosome
,
LocalDateTime
baseTime
,
GlobalParam
globalParam
,
List
<
Material
>
baseMaterialsSnapshot
,
boolean
removeGeneratedOrders
)
{
if
(
removeGeneratedOrders
)
{
DelOrder
(
chromosome
);
}
if
(
chromosome
.
getOrders
()
!=
null
)
{
chromosome
.
getOrders
().
forEach
(
order
->
order
.
setCreateBom
(
false
));
}
resetDecodeMaterials
(
chromosome
,
baseMaterialsSnapshot
);
MachineSchedulerService
machineScheduler
=
new
MachineSchedulerService
(
baseTime
);
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getInitMachines
(),
Machine
.
class
)
);
chromosome
.
getResult
().
clear
();
chromosome
.
setResult
(
new
CopyOnWriteArrayList
<>());
return
new
GeneticDecoder
(
globalParam
,
baseTime
,
chromosome
.
getMachines
(),
chromosome
.
getOrders
(),
null
,
machineScheduler
,
materialRequirementService
,
chromosome
.
getScenarioID
());
}
private
List
<
Material
>
resolveDecodeMaterials
(
Chromosome
chromosome
)
{
List
<
Material
>
useMaterials
=
materialRequirementService
.
GetMaterials
(
chromosome
.
getScenarioID
());
if
(
useMaterials
==
null
&&
chromosome
.
getMaterialIds
()
!=
null
&&
chromosome
.
getMaterialIds
().
size
()
>
0
)
{
List
<
Material
>
materials
=
planResultService
.
InitMaterial
();
useMaterials
=
materials
.
stream
()
.
filter
(
t
->
chromosome
.
getMaterialIds
().
contains
(
t
.
getId
()))
.
collect
(
Collectors
.
toList
());
}
if
(
useMaterials
==
null
)
{
useMaterials
=
new
ArrayList
<>();
}
return
ProductionDeepCopyUtil
.
deepCopyList
(
useMaterials
,
Material
.
class
);
}
private
void
resetDecodeMaterials
(
Chromosome
chromosome
,
List
<
Material
>
baseMaterialsSnapshot
)
{
List
<
Material
>
materialsForDecode
=
ProductionDeepCopyUtil
.
deepCopyList
(
baseMaterialsSnapshot
,
Material
.
class
);
chromosome
.
setMaterials
(
materialsForDecode
);
materialRequirementService
.
SetMaterials
(
chromosome
.
getScenarioID
(),
materialsForDecode
);
}
public
void
DelOrder
(
Chromosome
chromosome
)
{
public
void
DelOrder
(
Chromosome
chromosome
)
{
List
<
Entry
>
allOperations
=
chromosome
.
getAllOperations
();
List
<
Entry
>
allOperations
=
chromosome
.
getAllOperations
();
List
<
GlobalOperationInfo
>
globalOpList
=
chromosome
.
getGlobalOpList
();
List
<
GlobalOperationInfo
>
globalOpList
=
chromosome
.
getGlobalOpList
();
...
@@ -1914,7 +1936,7 @@ if(targetOp.getSequence()>1) {
...
@@ -1914,7 +1936,7 @@ if(targetOp.getSequence()>1) {
List
<
Integer
>
OperationSequencing
=
chromosome
.
getOperationSequencing
();
List
<
Integer
>
OperationSequencing
=
chromosome
.
getOperationSequencing
();
List
<
GAScheduleResult
>
ScheduleResults
=
chromosome
.
getResult
();
List
<
GAScheduleResult
>
ScheduleResults
=
chromosome
.
getResult
();
List
<
Integer
>
newoorderids
=
orders
.
stream
()
List
<
Integer
>
newoorderids
=
orders
.
stream
()
.
filter
(
t
->
t
.
isNew
Create
())
.
filter
(
t
->
t
.
isNewCreate
()
||
t
.
isNewSf
Create
())
.
map
(
Order:
:
getId
)
.
map
(
Order:
:
getId
)
.
sorted
(
Comparator
.
reverseOrder
())
.
sorted
(
Comparator
.
reverseOrder
())
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
8231751e
...
@@ -1867,6 +1867,7 @@ public class PlanResultService {
...
@@ -1867,6 +1867,7 @@ public class PlanResultService {
FileHelper
.
writeLogFile
(
String
.
format
(
"Setup Time: %f minutes"
,
schedule
.
getTotalChangeoverTime
()));
FileHelper
.
writeLogFile
(
String
.
format
(
"Setup Time: %f minutes"
,
schedule
.
getTotalChangeoverTime
()));
FileHelper
.
writeLogFile
(
String
.
format
(
"Flow Time: %f minutes"
,
schedule
.
getTotalFlowTime
()));
FileHelper
.
writeLogFile
(
String
.
format
(
"Flow Time: %f minutes"
,
schedule
.
getTotalFlowTime
()));
FileHelper
.
writeLogFile
(
String
.
format
(
"Machine Load Balance: %.2f%%"
,
schedule
.
getMachineLoadStd
()
*
100
));
FileHelper
.
writeLogFile
(
String
.
format
(
"Machine Load Balance: %.2f%%"
,
schedule
.
getMachineLoadStd
()
*
100
));
FileHelper
.
writeLogFile
(
String
.
format
(
"Semi JIT Slack: %f minutes"
,
schedule
.
getSemiJitSlack
()));
FileHelper
.
writeLogFile
(
"-------------------------"
);
FileHelper
.
writeLogFile
(
"-------------------------"
);
// 按订单分组写入
// 按订单分组写入
...
...
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