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
8c7f2c64
Commit
8c7f2c64
authored
May 14, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改物料list为map
parent
f3e148e7
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
100 additions
and
71 deletions
+100
-71
ProductionDeepCopyUtil.java
...main/java/com/aps/common/util/ProductionDeepCopyUtil.java
+13
-0
Chromosome.java
src/main/java/com/aps/entity/Algorithm/Chromosome.java
+2
-2
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+3
-3
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+2
-2
GeneticDecoderBom.java
...ain/java/com/aps/service/Algorithm/GeneticDecoderBom.java
+1
-1
HillClimbing.java
src/main/java/com/aps/service/Algorithm/HillClimbing.java
+3
-3
HybridAlgorithm.java
src/main/java/com/aps/service/Algorithm/HybridAlgorithm.java
+4
-4
MaterialRequirementService.java
...com/aps/service/Algorithm/MaterialRequirementService.java
+37
-26
PostEditJitService.java
...in/java/com/aps/service/Algorithm/PostEditJitService.java
+1
-2
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+14
-12
SimulatedAnnealing.java
...in/java/com/aps/service/Algorithm/SimulatedAnnealing.java
+3
-3
TabuSearch.java
src/main/java/com/aps/service/Algorithm/TabuSearch.java
+4
-4
VariableNeighborhoodSearch.java
...com/aps/service/Algorithm/VariableNeighborhoodSearch.java
+7
-7
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+6
-2
No files found.
src/main/java/com/aps/common/util/ProductionDeepCopyUtil.java
View file @
8c7f2c64
...
@@ -139,4 +139,17 @@ public class ProductionDeepCopyUtil {
...
@@ -139,4 +139,17 @@ public class ProductionDeepCopyUtil {
throw
new
RuntimeException
(
"Map深拷贝失败"
,
e
);
throw
new
RuntimeException
(
"Map深拷贝失败"
,
e
);
}
}
}
}
public
static
<
K
,
V
>
TreeMap
<
K
,
V
>
deepCopyTreeMap
(
TreeMap
<
K
,
V
>
source
,
Class
<
K
>
keyType
,
Class
<
V
>
valueType
)
{
if
(
source
==
null
)
{
return
new
TreeMap
<>();
}
try
{
String
json
=
objectMapper
.
writeValueAsString
(
source
);
return
objectMapper
.
readValue
(
json
,
objectMapper
.
getTypeFactory
().
constructMapType
(
TreeMap
.
class
,
keyType
,
valueType
));
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"TreeMap深拷贝失败"
,
e
);
}
}
}
}
\ No newline at end of file
src/main/java/com/aps/entity/Algorithm/Chromosome.java
View file @
8c7f2c64
...
@@ -127,9 +127,9 @@ public class Chromosome {
...
@@ -127,9 +127,9 @@ public class Chromosome {
private
ObjectiveWeights
objectiveWeights
;
private
ObjectiveWeights
objectiveWeights
;
// private Map<String,Material> materials = new Hash
Map<>();
private
TreeMap
<
String
,
Material
>
materials
=
new
Tree
Map
<>();
private
List
<
Material
>
materials
=
new
ArrayList
<>();
//
private List<Material> materials = new ArrayList<>();
private
List
<
String
>
materialIds
=
new
ArrayList
<>();
private
List
<
String
>
materialIds
=
new
ArrayList
<>();
/*
/*
...
...
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
8c7f2c64
...
@@ -25,7 +25,7 @@ public class GeneticAlgorithm {
...
@@ -25,7 +25,7 @@ public class GeneticAlgorithm {
private
List
<
Machine
>
machines
;
private
List
<
Machine
>
machines
;
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
TreeMap
<
String
,
Material
>
materials
;
private
final
List
<
String
>
materialIds
;
private
final
List
<
String
>
materialIds
;
...
@@ -49,7 +49,7 @@ public class GeneticAlgorithm {
...
@@ -49,7 +49,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
,
List
<
String
>
_materialIds
,
MachineSchedulerService
machineScheduler
,
List
<
GroupResult
>
entryRel
,
MaterialRequirementService
_materialRequirementService
,
SceneService
sceneService
,
String
_sceneId
)
{
TreeMap
<
String
,
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
;
...
@@ -398,7 +398,7 @@ public class GeneticAlgorithm {
...
@@ -398,7 +398,7 @@ public class GeneticAlgorithm {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
material
s
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
materials
,
String
.
clas
s
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setGlobalOpList
(
ProductionDeepCopyUtil
.
deepCopyList
(
globalOpList
,
GlobalOperationInfo
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setGlobalOpList
(
ProductionDeepCopyUtil
.
deepCopyList
(
globalOpList
,
GlobalOperationInfo
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
8c7f2c64
...
@@ -56,7 +56,7 @@ public class GeneticDecoder {
...
@@ -56,7 +56,7 @@ public class GeneticDecoder {
private
final
MachineSchedulerService
machineScheduler
;
private
final
MachineSchedulerService
machineScheduler
;
private
final
List
<
Order
>
orders
;
private
final
List
<
Order
>
orders
;
private
int
orderMaxID
;
private
int
orderMaxID
;
private
final
List
<
Material
>
materials
;
private
final
TreeMap
<
String
,
Material
>
materials
;
private
List
<
Entry
>
_allOperations
;
private
List
<
Entry
>
_allOperations
;
private
GlobalParam
_globalParam
;
private
GlobalParam
_globalParam
;
private
MachineCalculator
machineCalculator
;
private
MachineCalculator
machineCalculator
;
...
@@ -74,7 +74,7 @@ public class GeneticDecoder {
...
@@ -74,7 +74,7 @@ public class GeneticDecoder {
public
GeneticDecoder
(
GlobalParam
globalParam
,
LocalDateTime
baseTime
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
public
GeneticDecoder
(
GlobalParam
globalParam
,
LocalDateTime
baseTime
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
MaterialRequirementService
_materialRequirementService
,
String
_sceneId
)
{
TreeMap
<
String
,
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
MaterialRequirementService
_materialRequirementService
,
String
_sceneId
)
{
this
.
baseTime
=
baseTime
;
this
.
baseTime
=
baseTime
;
this
.
machines
=
machines
;
this
.
machines
=
machines
;
this
.
orders
=
orders
;
this
.
orders
=
orders
;
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoderBom.java
View file @
8c7f2c64
...
@@ -296,7 +296,7 @@ if(isJit)
...
@@ -296,7 +296,7 @@ if(isJit)
int
estimatedStartTime
,
int
estimatedStartTime
,
Map
<
Integer
,
List
<
Entry
>>
entrysBygroupId
,
Map
<
Integer
,
List
<
Entry
>>
entrysBygroupId
,
Chromosome
chromosome
)
{
Chromosome
chromosome
)
{
List
<
Material
>
materials
=
chromosome
.
getMaterials
();
TreeMap
<
String
,
Material
>
materials
=
chromosome
.
getMaterials
();
if
(
materials
==
null
||
materials
.
isEmpty
())
return
estimatedStartTime
;
if
(
materials
==
null
||
materials
.
isEmpty
())
return
estimatedStartTime
;
List
<
OrderMaterialRequirement
>
remove
=
new
ArrayList
<>();
List
<
OrderMaterialRequirement
>
remove
=
new
ArrayList
<>();
...
...
src/main/java/com/aps/service/Algorithm/HillClimbing.java
View file @
8c7f2c64
...
@@ -23,7 +23,7 @@ public class HillClimbing {
...
@@ -23,7 +23,7 @@ public class HillClimbing {
private
List
<
Entry
>
allOperations
;
private
List
<
Entry
>
allOperations
;
private
List
<
Order
>
orders
;
private
List
<
Order
>
orders
;
private
List
<
Material
>
materials
;
private
TreeMap
<
String
,
Material
>
materials
;
private
List
<
GroupResult
>
_entryRel
;
private
List
<
GroupResult
>
_entryRel
;
...
@@ -39,7 +39,7 @@ public class HillClimbing {
...
@@ -39,7 +39,7 @@ public class HillClimbing {
private
FitnessCalculator
fitnessCalculator
;
private
FitnessCalculator
fitnessCalculator
;
public
HillClimbing
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
public
HillClimbing
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
_fitnessCalculator
)
{
TreeMap
<
String
,
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
_fitnessCalculator
)
{
this
.
allOperations
=
allOperations
;
this
.
allOperations
=
allOperations
;
this
.
orders
=
orders
;
this
.
orders
=
orders
;
...
@@ -631,7 +631,7 @@ public class HillClimbing {
...
@@ -631,7 +631,7 @@ public class HillClimbing {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
material
s
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
materials
,
String
.
clas
s
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
//chromosome.setObjectiveWeights(_objectiveWeights);
//chromosome.setObjectiveWeights(_objectiveWeights);
...
...
src/main/java/com/aps/service/Algorithm/HybridAlgorithm.java
View file @
8c7f2c64
...
@@ -25,7 +25,7 @@ public class HybridAlgorithm {
...
@@ -25,7 +25,7 @@ public class HybridAlgorithm {
private
List
<
Machine
>
machines
;
private
List
<
Machine
>
machines
;
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
TreeMap
<
String
,
Material
>
materials
;
private
final
List
<
String
>
materialIds
;
private
final
List
<
String
>
materialIds
;
...
@@ -60,7 +60,7 @@ public class HybridAlgorithm {
...
@@ -60,7 +60,7 @@ public class HybridAlgorithm {
public
HybridAlgorithm
(
GlobalParam
globalParam
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
public
HybridAlgorithm
(
GlobalParam
globalParam
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
List
<
String
>
_materialIds
,
MachineSchedulerService
machineScheduler
,
List
<
GroupResult
>
entryRel
,
MaterialRequirementService
_materialRequirementService
,
SceneService
sceneService
,
String
_sceneId
)
{
TreeMap
<
String
,
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
;
...
@@ -428,7 +428,7 @@ public class HybridAlgorithm {
...
@@ -428,7 +428,7 @@ public class HybridAlgorithm {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
materials
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
materials
,
String
.
class
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setGlobalOpList
(
ProductionDeepCopyUtil
.
deepCopyList
(
globalOpList
,
GlobalOperationInfo
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setGlobalOpList
(
ProductionDeepCopyUtil
.
deepCopyList
(
globalOpList
,
GlobalOperationInfo
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
...
@@ -485,7 +485,7 @@ public class HybridAlgorithm {
...
@@ -485,7 +485,7 @@ public class HybridAlgorithm {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
materials
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
materials
,
String
.
class
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
// chromosome.setGlobalOpList(ProductionDeepCopyUtil.deepCopyList(globalOpList, GlobalOperationInfo.class) ); // 简单拷贝,实际可能需要深拷贝
// chromosome.setGlobalOpList(ProductionDeepCopyUtil.deepCopyList(globalOpList, GlobalOperationInfo.class) ); // 简单拷贝,实际可能需要深拷贝
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
8c7f2c64
...
@@ -37,7 +37,7 @@ import java.util.stream.IntStream;
...
@@ -37,7 +37,7 @@ import java.util.stream.IntStream;
@Service
@Service
public
class
MaterialRequirementService
{
public
class
MaterialRequirementService
{
private
List
<
Material
>
_materials
;
private
List
<
Material
>
_materials
;
@Autowired
@Autowired
...
@@ -208,6 +208,7 @@ public class MaterialRequirementService {
...
@@ -208,6 +208,7 @@ public class MaterialRequirementService {
reslte
.
put
(
1
,
equipids
);
reslte
.
put
(
1
,
equipids
);
}
}
List
<
Material
>
useMaterials1
=(
List
<
Material
>)
reslte1
.
get
(
2
);
List
<
Material
>
useMaterials1
=(
List
<
Material
>)
reslte1
.
get
(
2
);
if
(
useMaterials1
!=
null
)
{
if
(
useMaterials1
!=
null
)
{
for
(
Material
m:
useMaterials1
)
{
for
(
Material
m:
useMaterials1
)
{
String
materialID1
=
m
.
getId
();
String
materialID1
=
m
.
getId
();
...
@@ -646,17 +647,14 @@ if(demand==null)
...
@@ -646,17 +647,14 @@ if(demand==null)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
List
<
Order
>
orders
=
chromosome
.
getOrders
();
List
<
Order
>
orders
=
chromosome
.
getOrders
();
if
(
MaterialRequirements
!=
null
&&
MaterialRequirements
.
size
()>
0
)
{
if
(
MaterialRequirements
!=
null
&&
MaterialRequirements
.
size
()>
0
)
{
List
<
Material
>
_materials
=
GetMaterials
(
sceneId
);
TreeMap
<
String
,
Material
>
_materials
=
GetMaterials
(
sceneId
);
for
(
Routingsupporting
component
:
MaterialRequirements
)
{
for
(
Routingsupporting
component
:
MaterialRequirements
)
{
double
allneeded
=
component
.
getSpentQty
().
doubleValue
()/
component
.
getMainQty
().
doubleValue
()
*
parentQuantity
;
double
allneeded
=
component
.
getSpentQty
().
doubleValue
()/
component
.
getMainQty
().
doubleValue
()
*
parentQuantity
;
double
needed
=
allneeded
;
double
needed
=
allneeded
;
// 查找物料(流式处理替代First)
// 查找物料(流式处理替代First)
Material
material
=
_materials
.
stream
()
Material
material
=
_materials
.
get
(
component
.
getMaterialId
());
.
filter
(
m
->
m
.
getId
().
equals
(
component
.
getMaterialId
()))
.
findFirst
()
.
orElse
(
null
);
if
(
material
==
null
)
{
if
(
material
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -1179,7 +1177,7 @@ if(demand==null)
...
@@ -1179,7 +1177,7 @@ if(demand==null)
})
})
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
List
<
Material
>
materials
=
chromosome
.
getMaterials
();
TreeMap
<
String
,
Material
>
materials
=
chromosome
.
getMaterials
();
List
<
OrderMaterialRequirement
>
remove
=
new
ArrayList
<>();
List
<
OrderMaterialRequirement
>
remove
=
new
ArrayList
<>();
Map
<
String
,
OrderMaterialRequirement
>
totalNeededByMaterial
=
new
HashMap
<>();
Map
<
String
,
OrderMaterialRequirement
>
totalNeededByMaterial
=
new
HashMap
<>();
...
@@ -1211,7 +1209,7 @@ if(demand==null)
...
@@ -1211,7 +1209,7 @@ if(demand==null)
}
}
}
}
public
LocalDateTime
CalBom
(
Chromosome
chromosome
,
int
operationId
,
Map
<
String
,
OrderMaterialRequirement
>
MaterialRequirements
,
List
<
Material
>
materials
,
LocalDateTime
earliestStartTime
,
boolean
commitChanges
,
List
<
OrderMaterialRequirement
>
remove
,
Map
<
Integer
,
List
<
Entry
>>
entrysBygroupId
,
boolean
isSf
)
public
LocalDateTime
CalBom
(
Chromosome
chromosome
,
int
operationId
,
Map
<
String
,
OrderMaterialRequirement
>
MaterialRequirements
,
TreeMap
<
String
,
Material
>
materials
,
LocalDateTime
earliestStartTime
,
boolean
commitChanges
,
List
<
OrderMaterialRequirement
>
remove
,
Map
<
Integer
,
List
<
Entry
>>
entrysBygroupId
,
boolean
isSf
)
{
{
String
sceneId
=
chromosome
.
getScenarioID
();
String
sceneId
=
chromosome
.
getScenarioID
();
Random
rnd
=
new
Random
();
Random
rnd
=
new
Random
();
...
@@ -1226,10 +1224,7 @@ if(demand==null)
...
@@ -1226,10 +1224,7 @@ if(demand==null)
resetRequirementCalc
(
orderMaterial
);
resetRequirementCalc
(
orderMaterial
);
// 查找物料(流式处理替代First)
// 查找物料(流式处理替代First)
Material
material
=
materials
.
stream
()
Material
material
=
materials
.
get
(
orderMaterial
.
getMaterialId
());
.
filter
(
m
->
m
.
getId
().
equals
(
orderMaterial
.
getMaterialId
()))
.
findFirst
()
.
orElse
(
null
);
if
(
material
==
null
)
{
if
(
material
==
null
)
{
return
useTime1
;
return
useTime1
;
}
}
...
@@ -1287,10 +1282,7 @@ if(demand==null)
...
@@ -1287,10 +1282,7 @@ if(demand==null)
if
(
routingsupportingreplaces2
!=
null
&&
routingsupportingreplaces2
.
size
()
>
0
)
{
if
(
routingsupportingreplaces2
!=
null
&&
routingsupportingreplaces2
.
size
()
>
0
)
{
for
(
RoutingSupportingReplace
rsr
:
routingsupportingreplaces2
)
{
for
(
RoutingSupportingReplace
rsr
:
routingsupportingreplaces2
)
{
Material
material1
=
materials
.
stream
()
Material
material1
=
materials
.
get
(
rsr
.
getTargetmaterialid
());
.
filter
(
m
->
m
.
getId
().
equals
(
rsr
.
getTargetmaterialid
()))
.
findFirst
()
.
orElse
(
null
);
if
(
material1
==
null
)
{
if
(
material1
==
null
)
{
break
;
break
;
...
@@ -1343,10 +1335,8 @@ if(demand==null)
...
@@ -1343,10 +1335,8 @@ if(demand==null)
.
findFirst
()
.
findFirst
()
.
orElse
(
null
);
.
orElse
(
null
);
Material
material1
=
materials
.
stream
()
Material
material1
=
materials
.
get
(
orderMaterial1
.
getMaterialId
())
.
filter
(
m
->
m
.
getId
().
equals
(
orderMaterial1
.
getMaterialId
()))
;
.
findFirst
()
.
orElse
(
null
);
if
(
material1
==
null
)
{
if
(
material1
==
null
)
{
break
;
break
;
}
}
...
@@ -1530,16 +1520,13 @@ if(demand==null)
...
@@ -1530,16 +1520,13 @@ if(demand==null)
private
void
MaterialInTransit
(
Material
material
,
String
materialId
,
OrderMaterialRequirement
orderMaterial
,
double
needed
,
LocalDateTime
earliestStartTime
,
List
<
Material
>
materials
,
boolean
commitChanges
){
private
void
MaterialInTransit
(
Material
material
,
String
materialId
,
OrderMaterialRequirement
orderMaterial
,
double
needed
,
LocalDateTime
earliestStartTime
,
TreeMap
<
String
,
Material
>
materials
,
boolean
commitChanges
){
// 处理在途物料
// 处理在途物料
LocalDateTime
earliestTime
=
null
;
LocalDateTime
earliestTime
=
null
;
double
useTransit
=
0
;
double
useTransit
=
0
;
if
(
material
==
null
)
{
if
(
material
==
null
)
{
material
=
materials
.
stream
()
material
=
materials
.
get
(
materialId
);
.
filter
(
m
->
m
.
getId
().
equals
(
materialId
))
.
findFirst
()
.
orElse
(
null
);
if
(
material
==
null
)
{
if
(
material
==
null
)
{
return
;
return
;
}
}
...
@@ -1751,7 +1738,31 @@ if(demand==null)
...
@@ -1751,7 +1738,31 @@ if(demand==null)
return
RoutingDiscreteParams
;
return
RoutingDiscreteParams
;
}
}
public
List
<
Material
>
GetMaterials
(
String
sceneId
)
{
public
TreeMap
<
String
,
Material
>
GetMaterialListToMap
(
List
<
Material
>
materiallist
)
{
if
(
materiallist
==
null
)
return
null
;
TreeMap
<
String
,
Material
>
materials
=
materiallist
.
stream
()
.
collect
(
Collectors
.
toMap
(
// 1. Key映射:取Material.code
Material:
:
getId
,
// 2. Value映射:Material → Material
material
->
material
,
// 3. Key重复时的处理规则(保留旧值/覆盖新值)
(
oldValue
,
newValue
)
->
newValue
,
// 4. 指定返回TreeMap(有序)
TreeMap:
:
new
));
return
materials
;
}
public
TreeMap
<
String
,
Material
>
GetMaterials
(
String
sceneId
)
{
List
<
Material
>
materiallist
=
GetMaterialList
(
sceneId
);
if
(
materiallist
==
null
)
return
null
;
return
GetMaterialListToMap
(
materiallist
);
}
public
List
<
Material
>
GetMaterialList
(
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/PostEditJitService.java
View file @
8c7f2c64
...
@@ -49,8 +49,7 @@ public class PostEditJitService {
...
@@ -49,8 +49,7 @@ public class PostEditJitService {
.
collect
(
Collectors
.
groupingBy
(
Entry:
:
getGroupId
));
.
collect
(
Collectors
.
groupingBy
(
Entry:
:
getGroupId
));
Map
<
String
,
Material
>
materialsById
=
chromosome
.
getMaterials
()
==
null
Map
<
String
,
Material
>
materialsById
=
chromosome
.
getMaterials
()
==
null
?
Collections
.
emptyMap
()
?
Collections
.
emptyMap
()
:
chromosome
.
getMaterials
().
stream
()
:
chromosome
.
getMaterials
();
.
collect
(
Collectors
.
toMap
(
Material:
:
getId
,
m
->
m
,
(
left
,
right
)
->
left
));
Map
<
Integer
,
Set
<
Integer
>>
childGroupsByParentOp
=
buildChildGroupIndex
(
chromosome
.
getAllOperations
());
Map
<
Integer
,
Set
<
Integer
>>
childGroupsByParentOp
=
buildChildGroupIndex
(
chromosome
.
getAllOperations
());
if
(
childGroupsByParentOp
.
isEmpty
())
{
if
(
childGroupsByParentOp
.
isEmpty
())
{
...
...
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
8c7f2c64
...
@@ -1900,7 +1900,7 @@ if(targetOp.getSequence()>1) {
...
@@ -1900,7 +1900,7 @@ 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
);
TreeMap
<
String
,
Material
>
baseMaterialsSnapshot
=
resolveDecodeMaterials
(
chromosome
);
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getResult
(),
GAScheduleResult
.
class
));
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getResult
(),
GAScheduleResult
.
class
));
GeneticDecoder
decoder
=
prepareDecodePass
(
chromosome
,
baseTime
,
globalParam
,
baseMaterialsSnapshot
,
true
);
GeneticDecoder
decoder
=
prepareDecodePass
(
chromosome
,
baseTime
,
globalParam
,
baseMaterialsSnapshot
,
true
);
...
@@ -1927,7 +1927,7 @@ if(targetOp.getSequence()>1) {
...
@@ -1927,7 +1927,7 @@ if(targetOp.getSequence()>1) {
}
}
private
GeneticDecoder
prepareDecodePass
(
Chromosome
chromosome
,
LocalDateTime
baseTime
,
GlobalParam
globalParam
,
private
GeneticDecoder
prepareDecodePass
(
Chromosome
chromosome
,
LocalDateTime
baseTime
,
GlobalParam
globalParam
,
List
<
Material
>
baseMaterialsSnapshot
,
boolean
removeGeneratedOrders
)
{
TreeMap
<
String
,
Material
>
baseMaterialsSnapshot
,
boolean
removeGeneratedOrders
)
{
if
(
removeGeneratedOrders
)
{
if
(
removeGeneratedOrders
)
{
DelOrder
(
chromosome
);
DelOrder
(
chromosome
);
}
}
...
@@ -1947,24 +1947,26 @@ if(targetOp.getSequence()>1) {
...
@@ -1947,24 +1947,26 @@ if(targetOp.getSequence()>1) {
chromosome
.
getOrders
(),
null
,
machineScheduler
,
materialRequirementService
,
chromosome
.
getScenarioID
());
chromosome
.
getOrders
(),
null
,
machineScheduler
,
materialRequirementService
,
chromosome
.
getScenarioID
());
}
}
private
List
<
Material
>
resolveDecodeMaterials
(
Chromosome
chromosome
)
{
private
TreeMap
<
String
,
Material
>
resolveDecodeMaterials
(
Chromosome
chromosome
)
{
List
<
Material
>
useMaterials
=
materialRequirementService
.
GetMaterials
(
chromosome
.
getScenarioID
());
TreeMap
<
String
,
Material
>
useMaterials
=
materialRequirementService
.
GetMaterials
(
chromosome
.
getScenarioID
());
if
(
useMaterials
==
null
&&
chromosome
.
getMaterialIds
()
!=
null
&&
chromosome
.
getMaterialIds
().
size
()
>
0
)
{
if
(
useMaterials
==
null
&&
chromosome
.
getMaterialIds
()
!=
null
&&
chromosome
.
getMaterialIds
().
size
()
>
0
)
{
List
<
Material
>
materials
=
planResultService
.
InitMaterial
();
List
<
Material
>
materials
=
planResultService
.
InitMaterial
();
useMaterials
=
materials
.
stream
()
.
filter
(
t
->
chromosome
.
getMaterialIds
().
contains
(
t
.
getId
()))
useMaterials
=
materialRequirementService
.
GetMaterialListToMap
(
materials
);
.
collect
(
Collectors
.
toList
());
}
}
if
(
useMaterials
==
null
)
{
if
(
useMaterials
==
null
)
{
useMaterials
=
new
ArrayList
<>();
useMaterials
=
new
TreeMap
<>();
}
}
return
ProductionDeepCopyUtil
.
deepCopy
List
(
useMaterial
s
,
Material
.
class
);
return
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
useMaterials
,
String
.
clas
s
,
Material
.
class
);
}
}
private
void
resetDecodeMaterials
(
Chromosome
chromosome
,
List
<
Material
>
baseMaterialsSnapshot
)
{
private
void
resetDecodeMaterials
(
Chromosome
chromosome
,
TreeMap
<
String
,
Material
>
baseMaterialsSnapshot
)
{
List
<
Material
>
materialsForDecode
=
ProductionDeepCopyUtil
.
deepCopyList
(
baseMaterialsSnapshot
,
Material
.
class
);
TreeMap
<
String
,
Material
>
materialsForDecode
=
ProductionDeepCopyUtil
.
deepCopyTreeMap
(
baseMaterialsSnapshot
,
String
.
class
,
Material
.
class
);
chromosome
.
setMaterials
(
materialsForDecode
);
chromosome
.
setMaterials
(
materialsForDecode
);
materialRequirementService
.
SetMaterials
(
chromosome
.
getScenarioID
(),
materialsForDecode
);
materialRequirementService
.
SetMaterials
(
chromosome
.
getScenarioID
(),
materialsForDecode
.
entrySet
().
stream
().
map
(
Map
.
Entry
::
getValue
)
.
collect
(
Collectors
.
toList
()));
}
}
public
void
DelOrder
(
Chromosome
chromosome
)
{
public
void
DelOrder
(
Chromosome
chromosome
)
{
...
...
src/main/java/com/aps/service/Algorithm/SimulatedAnnealing.java
View file @
8c7f2c64
...
@@ -33,7 +33,7 @@ public class SimulatedAnnealing {
...
@@ -33,7 +33,7 @@ public class SimulatedAnnealing {
private
List
<
Entry
>
allOperations
;
private
List
<
Entry
>
allOperations
;
private
List
<
Order
>
orders
;
private
List
<
Order
>
orders
;
private
List
<
Material
>
materials
;
private
TreeMap
<
String
,
Material
>
materials
;
private
List
<
GroupResult
>
_entryRel
;
private
List
<
GroupResult
>
_entryRel
;
...
@@ -43,7 +43,7 @@ public class SimulatedAnnealing {
...
@@ -43,7 +43,7 @@ public class SimulatedAnnealing {
private
Map
<
Integer
,
Entry
>
entrybyids
;
private
Map
<
Integer
,
Entry
>
entrybyids
;
public
SimulatedAnnealing
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
public
SimulatedAnnealing
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
_fitnessCalculator
)
{
TreeMap
<
String
,
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
_fitnessCalculator
)
{
this
.
allOperations
=
allOperations
;
this
.
allOperations
=
allOperations
;
this
.
orders
=
orders
;
this
.
orders
=
orders
;
...
@@ -538,7 +538,7 @@ public class SimulatedAnnealing {
...
@@ -538,7 +538,7 @@ public class SimulatedAnnealing {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
,
Machine
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
_entryRel
),
GroupResult
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
materials
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
materials
,
String
.
class
,
Material
.
class
));
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
)
);
// 简单拷贝,实际可能需要深拷贝
//chromosome.setObjectiveWeights(_objectiveWeights);
//chromosome.setObjectiveWeights(_objectiveWeights);
...
...
src/main/java/com/aps/service/Algorithm/TabuSearch.java
View file @
8c7f2c64
...
@@ -37,13 +37,13 @@ public class TabuSearch {
...
@@ -37,13 +37,13 @@ public class TabuSearch {
private
List
<
Machine
>
cachedMachines
;
private
List
<
Machine
>
cachedMachines
;
private
List
<
Order
>
cachedOrders
;
private
List
<
Order
>
cachedOrders
;
private
List
<
GroupResult
>
cachedEntryRel
;
private
List
<
GroupResult
>
cachedEntryRel
;
private
List
<
Material
>
cachedMaterials
;
private
TreeMap
<
String
,
Material
>
cachedMaterials
;
private
List
<
Entry
>
cachedAllOperations
;
private
List
<
Entry
>
cachedAllOperations
;
// 渴望准则:记录最优解的 fitness
// 渴望准则:记录最优解的 fitness
private
double
[]
bestFitness
;
private
double
[]
bestFitness
;
public
TabuSearch
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
public
TabuSearch
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
_fitnessCalculator
)
{
TreeMap
<
String
,
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
_fitnessCalculator
)
{
this
.
tabuList
=
new
ArrayList
<>();
this
.
tabuList
=
new
ArrayList
<>();
// 工序越多,禁忌表越长(适配1000+工序)
// 工序越多,禁忌表越长(适配1000+工序)
...
@@ -54,7 +54,7 @@ public class TabuSearch {
...
@@ -54,7 +54,7 @@ public class TabuSearch {
cachedAllOperations
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
);
cachedAllOperations
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
);
cachedOrders
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
);
cachedOrders
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
);
cachedEntryRel
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
entryRel
),
GroupResult
.
class
);
cachedEntryRel
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
entryRel
),
GroupResult
.
class
);
cachedMaterials
=
ProductionDeepCopyUtil
.
deepCopy
List
(
material
s
,
Material
.
class
);
cachedMaterials
=
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
materials
,
String
.
clas
s
,
Material
.
class
);
}
}
...
@@ -337,7 +337,7 @@ public class TabuSearch {
...
@@ -337,7 +337,7 @@ public class TabuSearch {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedMachines
,
Machine
.
class
));
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedMachines
,
Machine
.
class
));
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedOrders
),
Order
.
class
));
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedOrders
),
Order
.
class
));
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedEntryRel
),
GroupResult
.
class
));
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedEntryRel
),
GroupResult
.
class
));
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
cachedMaterial
s
,
Material
.
class
));
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
cachedMaterials
,
String
.
clas
s
,
Material
.
class
));
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedAllOperations
),
Entry
.
class
));
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedAllOperations
),
Entry
.
class
));
// 加载锁定工单到ResultOld
// 加载锁定工单到ResultOld
...
...
src/main/java/com/aps/service/Algorithm/VariableNeighborhoodSearch.java
View file @
8c7f2c64
...
@@ -97,7 +97,7 @@ public class VariableNeighborhoodSearch {
...
@@ -97,7 +97,7 @@ public class VariableNeighborhoodSearch {
private
FitnessCalculator
fitnessCalculator
;
private
FitnessCalculator
fitnessCalculator
;
private
List
<
Order
>
orders
;
private
List
<
Order
>
orders
;
private
List
<
Material
>
materials
;
private
TreeMap
<
String
,
Material
>
materials
;
private
List
<
GroupResult
>
_entryRel
;
private
List
<
GroupResult
>
_entryRel
;
...
@@ -119,7 +119,7 @@ public class VariableNeighborhoodSearch {
...
@@ -119,7 +119,7 @@ public class VariableNeighborhoodSearch {
private
List
<
Machine
>
cachedMachines
;
private
List
<
Machine
>
cachedMachines
;
private
List
<
Order
>
cachedOrders
;
private
List
<
Order
>
cachedOrders
;
private
List
<
GroupResult
>
cachedEntryRel
;
private
List
<
GroupResult
>
cachedEntryRel
;
private
List
<
Material
>
cachedMaterials
;
private
TreeMap
<
String
,
Material
>
cachedMaterials
;
private
List
<
Entry
>
cachedAllOperations
;
private
List
<
Entry
>
cachedAllOperations
;
private
GeneticOperations
geneticOperations
;
private
GeneticOperations
geneticOperations
;
...
@@ -150,12 +150,12 @@ public class VariableNeighborhoodSearch {
...
@@ -150,12 +150,12 @@ public class VariableNeighborhoodSearch {
}
}
public
VariableNeighborhoodSearch
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
public
VariableNeighborhoodSearch
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
fitnessCalculator
)
{
TreeMap
<
String
,
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
fitnessCalculator
)
{
this
(
allOperations
,
orders
,
materials
,
entryRel
,
fitnessCalculator
,
1
);
this
(
allOperations
,
orders
,
materials
,
entryRel
,
fitnessCalculator
,
1
);
}
}
public
VariableNeighborhoodSearch
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
public
VariableNeighborhoodSearch
(
List
<
Entry
>
allOperations
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
TreeMap
<
String
,
Material
>
materials
,
List
<
GroupResult
>
entryRel
,
FitnessCalculator
fitnessCalculator
,
int
maxNoImproveRounds
)
{
FitnessCalculator
fitnessCalculator
,
int
maxNoImproveRounds
)
{
this
.
maxNoImproveRounds
=
maxNoImproveRounds
;
this
.
maxNoImproveRounds
=
maxNoImproveRounds
;
this
.
allOperations
=
allOperations
;
this
.
allOperations
=
allOperations
;
...
@@ -181,7 +181,7 @@ public class VariableNeighborhoodSearch {
...
@@ -181,7 +181,7 @@ public class VariableNeighborhoodSearch {
cachedAllOperations
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
);
cachedAllOperations
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
allOperations
),
Entry
.
class
);
cachedOrders
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
);
cachedOrders
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
orders
),
Order
.
class
);
cachedEntryRel
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
entryRel
),
GroupResult
.
class
);
cachedEntryRel
=
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
entryRel
),
GroupResult
.
class
);
cachedMaterials
=
ProductionDeepCopyUtil
.
deepCopy
List
(
material
s
,
Material
.
class
);
cachedMaterials
=
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
materials
,
String
.
clas
s
,
Material
.
class
);
// 初始化邻域结构统计
// 初始化邻域结构统计
...
@@ -2091,7 +2091,7 @@ public class VariableNeighborhoodSearch {
...
@@ -2091,7 +2091,7 @@ public class VariableNeighborhoodSearch {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedMachines
,
Machine
.
class
));
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedMachines
,
Machine
.
class
));
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedOrders
),
Order
.
class
));
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedOrders
),
Order
.
class
));
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedEntryRel
),
GroupResult
.
class
));
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedEntryRel
),
GroupResult
.
class
));
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
cachedMaterial
s
,
Material
.
class
));
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
cachedMaterials
,
String
.
clas
s
,
Material
.
class
));
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedAllOperations
),
Entry
.
class
));
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedAllOperations
),
Entry
.
class
));
// 加载锁定工单到ResultOld
// 加载锁定工单到ResultOld
...
@@ -2121,7 +2121,7 @@ public class VariableNeighborhoodSearch {
...
@@ -2121,7 +2121,7 @@ public class VariableNeighborhoodSearch {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedMachines
,
Machine
.
class
));
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedMachines
,
Machine
.
class
));
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedOrders
),
Order
.
class
));
chromosome
.
setOrders
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedOrders
),
Order
.
class
));
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedEntryRel
),
GroupResult
.
class
));
chromosome
.
setOperatRel
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedEntryRel
),
GroupResult
.
class
));
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
List
(
cachedMaterial
s
,
Material
.
class
));
chromosome
.
setMaterials
(
ProductionDeepCopyUtil
.
deepCopy
TreeMap
(
cachedMaterials
,
String
.
clas
s
,
Material
.
class
));
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedAllOperations
),
Entry
.
class
));
chromosome
.
setAllOperations
(
ProductionDeepCopyUtil
.
deepCopyList
(
new
CopyOnWriteArrayList
<>(
cachedAllOperations
),
Entry
.
class
));
// 加载锁定工单到ResultOld
// 加载锁定工单到ResultOld
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
8c7f2c64
...
@@ -244,8 +244,11 @@ public class PlanResultService {
...
@@ -244,8 +244,11 @@ public class PlanResultService {
// 4.5 在排产前标记锁定期工单占用的设备时间段
// 4.5 在排产前标记锁定期工单占用的设备时间段
lockedOrderProcessorService
.
markLockedOrdersOccupiedTime
(
machines
,
timeConfig
.
getBaseTime
());
lockedOrderProcessorService
.
markLockedOrdersOccupiedTime
(
machines
,
timeConfig
.
getBaseTime
());
TreeMap
<
String
,
Material
>
materialmap
=
materialRequirementService
.
GetMaterialListToMap
(
Materials1
);
// 5. 执行调度算法
// 5. 执行调度算法
HybridAlgorithm
scheduler
=
new
HybridAlgorithm
(
globalParam
,
machines
,
orders
,
Materials1
,
materialIds
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
HybridAlgorithm
scheduler
=
new
HybridAlgorithm
(
globalParam
,
machines
,
orders
,
materialmap
,
materialIds
,
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
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
...
@@ -1858,8 +1861,9 @@ public class PlanResultService {
...
@@ -1858,8 +1861,9 @@ 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
,
null
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
materialRequirementService
.
GetMaterialListToMap
(
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
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
...
...
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