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
e6d1ee93
Commit
e6d1ee93
authored
Feb 05, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://39.100.78.207:1213/tongli/hyh.apsj
parents
0b51cb1f
c5fa84a8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
33 deletions
+98
-33
Chromosome.java
src/main/java/com/aps/entity/Algorithm/Chromosome.java
+3
-1
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+10
-3
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+20
-0
MachineCalculator.java
...ain/java/com/aps/service/Algorithm/MachineCalculator.java
+8
-1
MaterialRequirementService.java
...com/aps/service/Algorithm/MaterialRequirementService.java
+3
-3
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+8
-1
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+42
-22
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+4
-2
No files found.
src/main/java/com/aps/entity/Algorithm/Chromosome.java
View file @
e6d1ee93
...
@@ -101,7 +101,9 @@ public class Chromosome {
...
@@ -101,7 +101,9 @@ public class Chromosome {
private
ObjectiveWeights
objectiveWeights
;
private
ObjectiveWeights
objectiveWeights
;
List
<
Material
>
materials
;
private
List
<
Material
>
materials
;
private
List
<
String
>
materialIds
;
/*
/*
* 最早完工时间(最小化) 最小化总加工时间 最小总换型时间
* 最早完工时间(最小化) 最小化总加工时间 最小总换型时间
*/
*/
...
...
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
e6d1ee93
...
@@ -29,6 +29,9 @@ public class GeneticAlgorithm {
...
@@ -29,6 +29,9 @@ public class GeneticAlgorithm {
private
final
MachineSchedulerService
machineScheduler
;
private
final
MachineSchedulerService
machineScheduler
;
private
final
List
<
Order
>
orders
;
private
final
List
<
Order
>
orders
;
private
final
List
<
Material
>
materials
;
private
final
List
<
Material
>
materials
;
private
final
List
<
String
>
materialIds
;
private
static
GlobalParam
_GlobalParam
;
private
static
GlobalParam
_GlobalParam
;
private
List
<
GroupResult
>
_entryRel
;
private
List
<
GroupResult
>
_entryRel
;
...
@@ -49,7 +52,7 @@ public class GeneticAlgorithm {
...
@@ -49,7 +52,7 @@ public class GeneticAlgorithm {
private
String
sceneId
;
private
String
sceneId
;
public
GeneticAlgorithm
(
GlobalParam
globalParam
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
public
GeneticAlgorithm
(
GlobalParam
globalParam
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
List
<
GroupResult
>
entryRel
,
MaterialRequirementService
_materialRequirementService
,
SceneService
sceneService
,
String
_sceneId
)
{
List
<
Material
>
materials
,
List
<
String
>
_materialIds
,
MachineSchedulerService
machineScheduler
,
List
<
GroupResult
>
entryRel
,
MaterialRequirementService
_materialRequirementService
,
SceneService
sceneService
,
String
_sceneId
)
{
this
.
machines
=
machines
;
this
.
machines
=
machines
;
this
.
orders
=
orders
;
this
.
orders
=
orders
;
this
.
materials
=
materials
;
this
.
materials
=
materials
;
...
@@ -59,6 +62,7 @@ public class GeneticAlgorithm {
...
@@ -59,6 +62,7 @@ public class GeneticAlgorithm {
materialRequirementService
=
_materialRequirementService
;
materialRequirementService
=
_materialRequirementService
;
_sceneService
=
sceneService
;
_sceneService
=
sceneService
;
sceneId
=
_sceneId
;
sceneId
=
_sceneId
;
materialIds
=
_materialIds
;
}
}
public
void
Init
(
double
[]
customWeights
,
boolean
pureNSGAIIMode
)
{
public
void
Init
(
double
[]
customWeights
,
boolean
pureNSGAIIMode
)
{
...
@@ -127,7 +131,9 @@ public class GeneticAlgorithm {
...
@@ -127,7 +131,9 @@ public class GeneticAlgorithm {
if
(
population
.
size
()<
param
.
getTournamentSize
())
if
(
population
.
size
()<
param
.
getTournamentSize
())
{
{
best
.
setBaseTime
(
param
.
getBaseTime
());
best
.
setBaseTime
(
param
.
getBaseTime
());
best
.
setOrderMaterials
(
orderMaterials
);
// best.setOrderMaterials(orderMaterials);
best
.
setMaterialIds
(
materialIds
);
best
.
setMaterials
(
null
);
// best.setOperatRel(_entryRel);
// best.setOperatRel(_entryRel);
if
(
best
.
getInitMachines
()==
null
)
if
(
best
.
getInitMachines
()==
null
)
...
@@ -267,7 +273,8 @@ public class GeneticAlgorithm {
...
@@ -267,7 +273,8 @@ public class GeneticAlgorithm {
FileHelper
.
writeLogFile
(
"迭代进化-----------结束-------"
);
FileHelper
.
writeLogFile
(
"迭代进化-----------结束-------"
);
best
.
setBaseTime
(
param
.
getBaseTime
());
best
.
setBaseTime
(
param
.
getBaseTime
());
best
.
setOrderMaterials
(
orderMaterials
);
best
.
setMaterialIds
(
materialIds
);
best
.
setMaterials
(
null
);
// best.setOperatRel(_entryRel);
// best.setOperatRel(_entryRel);
if
(
best
.
getInitMachines
()==
null
)
if
(
best
.
getInitMachines
()==
null
)
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
e6d1ee93
...
@@ -499,6 +499,22 @@ if(finishedOrder==null||finishedOrder.size()==0)
...
@@ -499,6 +499,22 @@ if(finishedOrder==null||finishedOrder.size()==0)
// _globalParam.set_smoothChangeOver(false);
// _globalParam.set_smoothChangeOver(false);
CopyOnWriteArrayList
<
ScheduleResultDetail
>
geneDetails
=
new
CopyOnWriteArrayList
<>();
CopyOnWriteArrayList
<
ScheduleResultDetail
>
geneDetails
=
new
CopyOnWriteArrayList
<>();
int
bomtime
=
0
;
int
bomtime
=
0
;
if
(
machine
.
getId
()==
2063
)
{
int
i
=
0
;
}
LocalDateTime
startTime1
=
baseTime
.
plus
(
earliestStartTime
,
ChronoUnit
.
SECONDS
);
TimeSegment
slot
=
machineCalculator
.
GetCurrentOrNextShift
(
machine
,
startTime1
,
""
,
false
);
if
(
slot
!=
null
)
{
earliestStartTime
=
slot
.
getStart
().
isAfter
(
startTime1
)
?(
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
slot
.
getStart
())
:
earliestStartTime
;
}
if
((
operation
.
getMaterialRequirements
()!=
null
&&
operation
.
getTargetFinishedOperationId
()==
null
)||
calbom
)
{
if
((
operation
.
getMaterialRequirements
()!=
null
&&
operation
.
getTargetFinishedOperationId
()==
null
)||
calbom
)
{
int
earliestStartTimeold
=
earliestStartTime
;
int
earliestStartTimeold
=
earliestStartTime
;
if
(
_globalParam
.
is_smoothChangeOver
())
{
if
(
_globalParam
.
is_smoothChangeOver
())
{
...
@@ -518,6 +534,10 @@ if(finishedOrder==null||finishedOrder.size()==0)
...
@@ -518,6 +534,10 @@ if(finishedOrder==null||finishedOrder.size()==0)
earliestStartTime
=
bomtime
;
earliestStartTime
=
bomtime
;
}
}
}
}
if
(
machine
.
getId
()==
2063
)
{
int
i
=
0
;
}
...
...
src/main/java/com/aps/service/Algorithm/MachineCalculator.java
View file @
e6d1ee93
...
@@ -519,6 +519,13 @@ public class MachineCalculator {
...
@@ -519,6 +519,13 @@ public class MachineCalculator {
// 计算有效时间
// 计算有效时间
CopyOnWriteArrayList
<
TimeSegment
>
timeSegments2
=
new
CopyOnWriteArrayList
<>(
timeSegments
.
subList
(
1
,
timeSegments
.
size
()-
1
));
CopyOnWriteArrayList
<
TimeSegment
>
timeSegments2
=
new
CopyOnWriteArrayList
<>(
timeSegments
.
subList
(
1
,
timeSegments
.
size
()-
1
));
if
(
timeSegments2
==
null
||
timeSegments2
.
size
()==
0
)
{
int
i
=
0
;
}
LocalDateTime
effectiveStart
=
timeSegments2
.
get
(
0
).
getStart
();
LocalDateTime
effectiveStart
=
timeSegments2
.
get
(
0
).
getStart
();
LocalDateTime
effectiveend
=
timeSegments2
.
get
(
timeSegments2
.
size
()-
1
).
getEnd
();
LocalDateTime
effectiveend
=
timeSegments2
.
get
(
timeSegments2
.
size
()-
1
).
getEnd
();
...
@@ -1032,7 +1039,7 @@ public class MachineCalculator {
...
@@ -1032,7 +1039,7 @@ public class MachineCalculator {
/**
/**
* 获取设备当前或下一个有效班次
* 获取设备当前或下一个有效班次
*/
*/
p
rivate
TimeSegment
GetCurrentOrNextShift
(
Machine
machine
,
LocalDateTime
time
,
String
prevtime
,
boolean
checkprevtime
)
{
p
ublic
TimeSegment
GetCurrentOrNextShift
(
Machine
machine
,
LocalDateTime
time
,
String
prevtime
,
boolean
checkprevtime
)
{
TimeSegment
start
=
null
;
TimeSegment
start
=
null
;
if
(!
machine
.
getAvailability
().
isEmpty
())
if
(!
machine
.
getAvailability
().
isEmpty
())
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
e6d1ee93
...
@@ -832,7 +832,7 @@ if(headers1==null)
...
@@ -832,7 +832,7 @@ if(headers1==null)
if
(
MaterialRequirements
!=
null
&&
MaterialRequirements
.
size
()>
0
)
{
if
(
MaterialRequirements
!=
null
&&
MaterialRequirements
.
size
()>
0
)
{
for
(
OrderMaterialRequirement
orderMaterial
:
MaterialRequirements
)
{
for
(
OrderMaterialRequirement
orderMaterial
:
MaterialRequirements
)
{
double
allneeded
=
parentQuantity
*
orderMaterial
.
getRequiredQuantity
();
double
allneeded
=
orderMaterial
.
getRequiredQuantity
();
double
needed
=
allneeded
;
double
needed
=
allneeded
;
...
@@ -1277,7 +1277,7 @@ if(headers1==null)
...
@@ -1277,7 +1277,7 @@ if(headers1==null)
Long
CkeckLeadTime
=
material
.
getCkeckLeadTime
();
Long
CkeckLeadTime
=
material
.
getCkeckLeadTime
();
List
<
MaterialSupply
>
sortedInTransit
=
material
.
getInTransit
().
stream
()
List
<
MaterialSupply
>
sortedInTransit
=
material
.
getInTransit
().
stream
()
.
filter
(
t
->
t
.
getQuantity
()
>
0
&&
t
.
getArrivalTime
().
compareTo
(
earliestStartTime
)<=
0
)
.
filter
(
t
->
t
.
getQuantity
()
>
0
&&
t
.
getArrivalTime
().
compareTo
(
earliestStartTime
)<=
0
)
.
sorted
(
Comparator
.
comparing
(
MaterialSupply:
:
getArrivalTime
))
.
sorted
(
Comparator
.
comparing
(
MaterialSupply:
:
getArrivalTime
)
.
reversed
()
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
for
(
MaterialSupply
supply
:
sortedInTransit
)
{
for
(
MaterialSupply
supply
:
sortedInTransit
)
{
...
@@ -1418,7 +1418,7 @@ if(headers1==null)
...
@@ -1418,7 +1418,7 @@ if(headers1==null)
return
RoutingDiscreteParams
;
return
RoutingDiscreteParams
;
}
}
p
rivate
List
<
Material
>
GetMaterials
(
String
sceneId
)
{
p
ublic
List
<
Material
>
GetMaterials
(
String
sceneId
)
{
List
<
Material
>
materials
=(
List
<
Material
>)
GlobalCacheUtil
.
get
(
sceneId
+
materialsCacheKey
);
List
<
Material
>
materials
=(
List
<
Material
>)
GlobalCacheUtil
.
get
(
sceneId
+
materialsCacheKey
);
if
(
materials
==
null
)
if
(
materials
==
null
)
{
{
...
...
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
e6d1ee93
...
@@ -23,6 +23,13 @@ import java.util.stream.IntStream;
...
@@ -23,6 +23,13 @@ import java.util.stream.IntStream;
*/
*/
public
class
ScheduleOperationService
{
public
class
ScheduleOperationService
{
private
MaterialRequirementService
materialRequirementService
;
public
ScheduleOperationService
(
MaterialRequirementService
_materialRequirementService
)
{
materialRequirementService
=
_materialRequirementService
;
}
/**
/**
* 移动工序方法
* 移动工序方法
* @param chromosome 染色体对象
* @param chromosome 染色体对象
...
@@ -1214,7 +1221,7 @@ if(targetOp.getSequence()>1) {
...
@@ -1214,7 +1221,7 @@ if(targetOp.getSequence()>1) {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getInitMachines
(),
Machine
.
class
)
);
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getInitMachines
(),
Machine
.
class
)
);
GeneticDecoder
decoder
=
new
GeneticDecoder
(
globalParam
,
baseTime
,
chromosome
.
getMachines
(),
GeneticDecoder
decoder
=
new
GeneticDecoder
(
globalParam
,
baseTime
,
chromosome
.
getMachines
(),
chromosome
.
getOrders
(),
null
,
machineScheduler
,
null
,
chromosome
.
getScenarioID
());
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
();
chromosome
.
getResult
().
clear
();
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
e6d1ee93
...
@@ -161,6 +161,8 @@ public class PlanResultService {
...
@@ -161,6 +161,8 @@ public class PlanResultService {
List
<
Machine
>
machines
=
InitCalendarToAllMachines
(
SceneId
,
ProdEquipments
,
machineScheduler
,
globalParam
.
isIsUseCalendar
());
List
<
Machine
>
machines
=
InitCalendarToAllMachines
(
SceneId
,
ProdEquipments
,
machineScheduler
,
globalParam
.
isIsUseCalendar
());
// 3. 构建订单-工序数据
// 3. 构建订单-工序数据
List
<
Order
>
orders
=
InitOrder
(
ProdLaunchOrders
);
List
<
Order
>
orders
=
InitOrder
(
ProdLaunchOrders
);
List
<
Material
>
Materials
=
InitMaterial
();
List
<
Material
>
Materials
=
InitMaterial
();
...
@@ -202,8 +204,13 @@ public class PlanResultService {
...
@@ -202,8 +204,13 @@ public class PlanResultService {
);
);
List
<
String
>
materialIds
=
Materials1
.
stream
()
.
map
(
Material:
:
getId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
// 5. 执行调度算法
// 5. 执行调度算法
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials1
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials1
,
ma
terialIds
,
ma
chineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
param
.
initAdaptiveParams
(
entrys
.
size
());
param
.
initAdaptiveParams
(
entrys
.
size
());
double
[]
customWeights
=
new
double
[]
{
0.4
,
0.1
,
0.1
,
0.1
,
0.3
};
// 延迟时间权重提升到0.5
double
[]
customWeights
=
new
double
[]
{
0.4
,
0.1
,
0.1
,
0.1
,
0.3
};
// 延迟时间权重提升到0.5
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
...
@@ -253,7 +260,7 @@ public class PlanResultService {
...
@@ -253,7 +260,7 @@ public class PlanResultService {
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
WriteScheduleSummary
(
chromosome
);
WriteScheduleSummary
(
chromosome
);
ScheduleOperation
.
editMachineOption
(
chromosome
,
operation
,
newMachineId
,
globalParam
);
ScheduleOperation
.
editMachineOption
(
chromosome
,
operation
,
newMachineId
,
globalParam
);
WriteScheduleSummary
(
chromosome
);
WriteScheduleSummary
(
chromosome
);
...
@@ -344,7 +351,7 @@ public class PlanResultService {
...
@@ -344,7 +351,7 @@ public class PlanResultService {
.
forEach
(
opInfo
->
opInfo
.
setOp
(
operation
));
.
forEach
(
opInfo
->
opInfo
.
setOp
(
operation
));
}
}
GlobalParam
globalParam
=
new
GlobalParam
();
GlobalParam
globalParam
=
new
GlobalParam
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
editMachineOption
(
chromosome
,
operation
,
operation
.
getSelectMachineID
(),
globalParam
);
ScheduleOperation
.
editMachineOption
(
chromosome
,
operation
,
operation
.
getSelectMachineID
(),
globalParam
);
...
@@ -376,7 +383,7 @@ public class PlanResultService {
...
@@ -376,7 +383,7 @@ public class PlanResultService {
public
void
UnlockStartTime
(
String
sceneId
,
int
opId
)
{
public
void
UnlockStartTime
(
String
sceneId
,
int
opId
)
{
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
sceneId
);
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
sceneId
);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
UnlockStartTime
(
chromosome
,
opId
);
ScheduleOperation
.
UnlockStartTime
(
chromosome
,
opId
);
_sceneService
.
saveChromosomeToFile
(
chromosome
,
sceneId
);
_sceneService
.
saveChromosomeToFile
(
chromosome
,
sceneId
);
...
@@ -385,7 +392,7 @@ public class PlanResultService {
...
@@ -385,7 +392,7 @@ public class PlanResultService {
public
void
unlockStartTime
(
Chromosome
chromosome
,
int
opId
)
{
public
void
unlockStartTime
(
Chromosome
chromosome
,
int
opId
)
{
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
UnlockStartTime
(
chromosome
,
opId
);
ScheduleOperation
.
UnlockStartTime
(
chromosome
,
opId
);
}
}
...
@@ -423,7 +430,7 @@ public class PlanResultService {
...
@@ -423,7 +430,7 @@ public class PlanResultService {
*/
*/
private
Chromosome
redecodeChromosome
(
Chromosome
chromosome
,
String
SceneId
)
{
private
Chromosome
redecodeChromosome
(
Chromosome
chromosome
,
String
SceneId
)
{
GlobalParam
globalParam
=
new
GlobalParam
();
GlobalParam
globalParam
=
new
GlobalParam
();
ScheduleOperationService
scheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
scheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
scheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
scheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
// _sceneService.saveChromosomeToFile(chromosome, SceneId);
// _sceneService.saveChromosomeToFile(chromosome, SceneId);
return
chromosome
;
return
chromosome
;
...
@@ -436,7 +443,7 @@ public class PlanResultService {
...
@@ -436,7 +443,7 @@ public class PlanResultService {
}
}
chromosome
.
setBaseTime
(
BaseTime
);
chromosome
.
setBaseTime
(
BaseTime
);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
GlobalParam
globalParam
=
new
GlobalParam
();
GlobalParam
globalParam
=
new
GlobalParam
();
ScheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
ScheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
...
@@ -452,7 +459,7 @@ public class PlanResultService {
...
@@ -452,7 +459,7 @@ public class PlanResultService {
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperation
.
dragOperation
(
chromosome
,
opId
,
targetopId
,
isfront
,
newMachineId
,
globalParam
);
ScheduleOperation
.
dragOperation
(
chromosome
,
opId
,
targetopId
,
isfront
,
newMachineId
,
globalParam
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -469,7 +476,7 @@ public class PlanResultService {
...
@@ -469,7 +476,7 @@ public class PlanResultService {
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperation
.
moveOperation
(
chromosome
,
opId
,
(
int
)
ChronoUnit
.
SECONDS
.
between
(
chromosome
.
getBaseTime
(),
newStartTime
),
newMachineId
,
globalParam
,
lockStartTime
);
ScheduleOperation
.
moveOperation
(
chromosome
,
opId
,
(
int
)
ChronoUnit
.
SECONDS
.
between
(
chromosome
.
getBaseTime
(),
newStartTime
),
newMachineId
,
globalParam
,
lockStartTime
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -490,7 +497,7 @@ public class PlanResultService {
...
@@ -490,7 +497,7 @@ public class PlanResultService {
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperation
.
moveOperation
(
chromosome
,
opId
,
(
int
)
ChronoUnit
.
SECONDS
.
between
(
chromosome
.
getBaseTime
(),
newStartTime
),
newMachineId
,
globalParam
,
lockStartTime
);
ScheduleOperation
.
moveOperation
(
chromosome
,
opId
,
(
int
)
ChronoUnit
.
SECONDS
.
between
(
chromosome
.
getBaseTime
(),
newStartTime
),
newMachineId
,
globalParam
,
lockStartTime
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -502,9 +509,22 @@ public class PlanResultService {
...
@@ -502,9 +509,22 @@ public class PlanResultService {
public
void
Redecode
(
String
SceneId
)
public
void
Redecode
(
String
SceneId
)
{
{
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
List
<
Material
>
UseMaterials
=
materialRequirementService
.
GetMaterials
(
SceneId
);
if
(
UseMaterials
==
null
)
{
if
(
chromosome
.
getMaterialIds
()
!=
null
&&
chromosome
.
getMaterialIds
().
size
()
>
0
)
{
List
<
Material
>
Materials
=
InitMaterial
();
UseMaterials
=
Materials
.
stream
()
.
filter
(
t
->
chromosome
.
getMaterialIds
()
.
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
chromosome
.
setMaterials
(
UseMaterials
);
}
}
else
{
chromosome
.
setMaterials
(
UseMaterials
);
}
GlobalParam
globalParam
=
new
GlobalParam
();
GlobalParam
globalParam
=
new
GlobalParam
();
ScheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
ScheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -520,7 +540,7 @@ public class PlanResultService {
...
@@ -520,7 +540,7 @@ public class PlanResultService {
//this.baseTime=param.getBaseTime();
//this.baseTime=param.getBaseTime();
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
SpiltOperation
(
chromosome
,
opId
,
splitCounts
,
globalParam
);
ScheduleOperation
.
SpiltOperation
(
chromosome
,
opId
,
splitCounts
,
globalParam
);
WriteScheduleSummary
(
chromosome
);
WriteScheduleSummary
(
chromosome
);
...
@@ -537,7 +557,7 @@ public class PlanResultService {
...
@@ -537,7 +557,7 @@ public class PlanResultService {
//this.baseTime=param.getBaseTime();
//this.baseTime=param.getBaseTime();
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
DelOperation
(
chromosome
,
opId
,
globalParam
);
ScheduleOperation
.
DelOperation
(
chromosome
,
opId
,
globalParam
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -554,7 +574,7 @@ public class PlanResultService {
...
@@ -554,7 +574,7 @@ public class PlanResultService {
//this.baseTime=param.getBaseTime();
//this.baseTime=param.getBaseTime();
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
DelOrder
(
chromosome
,
orderId
,
globalParam
);
ScheduleOperation
.
DelOrder
(
chromosome
,
orderId
,
globalParam
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -574,7 +594,7 @@ public class PlanResultService {
...
@@ -574,7 +594,7 @@ public class PlanResultService {
//this.baseTime=param.getBaseTime();
//this.baseTime=param.getBaseTime();
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
LockOperation
(
chromosome
,
opId
,
isLocked
,
globalParam
);
ScheduleOperation
.
LockOperation
(
chromosome
,
opId
,
isLocked
,
globalParam
);
//WriteScheduleSummary(chromosome);
//WriteScheduleSummary(chromosome);
...
@@ -591,7 +611,7 @@ public class PlanResultService {
...
@@ -591,7 +611,7 @@ public class PlanResultService {
//this.baseTime=param.getBaseTime();
//this.baseTime=param.getBaseTime();
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
SpiltOrder
(
chromosome
,
orderId
,
splitCounts
,
globalParam
);
ScheduleOperation
.
SpiltOrder
(
chromosome
,
orderId
,
splitCounts
,
globalParam
);
WriteScheduleSummary
(
chromosome
);
WriteScheduleSummary
(
chromosome
);
...
@@ -607,7 +627,7 @@ public class PlanResultService {
...
@@ -607,7 +627,7 @@ public class PlanResultService {
//this.baseTime=param.getBaseTime();
//this.baseTime=param.getBaseTime();
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
MergeOrder
(
chromosome
,
sourceorderId
,
targetorderId
,
globalParam
);
ScheduleOperation
.
MergeOrder
(
chromosome
,
sourceorderId
,
targetorderId
,
globalParam
);
WriteScheduleSummary
(
chromosome
);
WriteScheduleSummary
(
chromosome
);
...
@@ -623,7 +643,7 @@ public class PlanResultService {
...
@@ -623,7 +643,7 @@ public class PlanResultService {
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
AddMaintenanceWindow
(
chromosome
,
machineId
,
maintenanceWindow
,
globalParam
);
ScheduleOperation
.
AddMaintenanceWindow
(
chromosome
,
machineId
,
maintenanceWindow
,
globalParam
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -640,7 +660,7 @@ public class PlanResultService {
...
@@ -640,7 +660,7 @@ public class PlanResultService {
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
DelMaintenanceWindow
(
chromosome
,
machineId
,
maintenanceId
,
globalParam
);
ScheduleOperation
.
DelMaintenanceWindow
(
chromosome
,
machineId
,
maintenanceId
,
globalParam
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -653,7 +673,7 @@ public class PlanResultService {
...
@@ -653,7 +673,7 @@ public class PlanResultService {
GlobalParam
globalParam
=
new
GlobalParam
();
GlobalParam
globalParam
=
new
GlobalParam
();
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
ScheduleOperation
.
DelMaintenanceWindowBatch
(
chromosome
,
machineId
,
maintenanceIds
,
globalParam
);
ScheduleOperation
.
DelMaintenanceWindowBatch
(
chromosome
,
machineId
,
maintenanceIds
,
globalParam
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -670,7 +690,7 @@ public class PlanResultService {
...
@@ -670,7 +690,7 @@ public class PlanResultService {
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
);
List
<
MaintenanceWindow
>
maintenanceWindowList
=
ScheduleOperation
.
GetMaintenanceWindow
(
chromosome
,
machineId
);
List
<
MaintenanceWindow
>
maintenanceWindowList
=
ScheduleOperation
.
GetMaintenanceWindow
(
chromosome
,
machineId
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
...
@@ -758,7 +778,7 @@ public class PlanResultService {
...
@@ -758,7 +778,7 @@ public class PlanResultService {
machines
=
machines
.
stream
().
filter
(
t
->
machineIds
.
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
machines
=
machines
.
stream
().
filter
(
t
->
machineIds
.
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
// 5. 执行调度算法
// 5. 执行调度算法
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials
,
null
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
param
.
initAdaptiveParams
(
entrys
.
size
());
param
.
initAdaptiveParams
(
entrys
.
size
());
double
[]
customWeights
=
new
double
[]
{
0.4
,
0.1
,
0.1
,
0.1
,
0.3
};
// 延迟时间权重提升到0.5
double
[]
customWeights
=
new
double
[]
{
0.4
,
0.1
,
0.1
,
0.1
,
0.3
};
// 延迟时间权重提升到0.5
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
e6d1ee93
...
@@ -39,7 +39,9 @@ public class PlanResultServiceTest {
...
@@ -39,7 +39,9 @@ public class PlanResultServiceTest {
// TestSortService sortService=new TestSortService();
// TestSortService sortService=new TestSortService();
// sortService.test1();
// sortService.test1();
// nsgaiiUtils.Test();
// nsgaiiUtils.Test();
planResultService
.
execute2
(
"18E5F8BE09B14EAE822651BFEF100900"
);
// planResultService.execute2("1BC8FFD1A7D54AE7AA75D2CBC7C08080");
// planResultService.execute2("00E0C5D3E4AD4F36B56C39395906618D");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
...
@@ -47,7 +49,7 @@ public class PlanResultServiceTest {
...
@@ -47,7 +49,7 @@ public class PlanResultServiceTest {
// opids.add(7);
// opids.add(7);
// planResultService.Move("27065EA0ECD14A81B7FAAFEF52273F93",opids,t,1265l,0);
// planResultService.Move("27065EA0ECD14A81B7FAAFEF52273F93",opids,t,1265l,0);
// planResultService.Redecode("27065EA0ECD14A81B7FAAFEF52273F93");
// planResultService.Redecode("27065EA0ECD14A81B7FAAFEF52273F93");
// planResultService.Redecode("CA71321FE55B4437A3900315692F9220
");
planResultService
.
Redecode
(
"00E0C5D3E4AD4F36B56C39395906618D
"
);
// planResultService.Drag("27065EA0ECD14A81B7FAAFEF52273F93",opids,6,false,0l);
// planResultService.Drag("27065EA0ECD14A81B7FAAFEF52273F93",opids,6,false,0l);
// MaintenanceWindow maintenanceWindow=new MaintenanceWindow();
// MaintenanceWindow maintenanceWindow=new MaintenanceWindow();
// maintenanceWindow.setStartTime(LocalDateTime.of(2025, 10, 21, 0, 0, 0));
// maintenanceWindow.setStartTime(LocalDateTime.of(2025, 10, 21, 0, 0, 0));
...
...
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