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
f0fc8121
Commit
f0fc8121
authored
Feb 05, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bom
parent
5256f110
Expand all
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 @
f0fc8121
...
...
@@ -101,7 +101,9 @@ public class Chromosome {
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 @
f0fc8121
...
...
@@ -29,6 +29,9 @@ public class GeneticAlgorithm {
private
final
MachineSchedulerService
machineScheduler
;
private
final
List
<
Order
>
orders
;
private
final
List
<
Material
>
materials
;
private
final
List
<
String
>
materialIds
;
private
static
GlobalParam
_GlobalParam
;
private
List
<
GroupResult
>
_entryRel
;
...
...
@@ -49,7 +52,7 @@ public class GeneticAlgorithm {
private
String
sceneId
;
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
.
orders
=
orders
;
this
.
materials
=
materials
;
...
...
@@ -59,6 +62,7 @@ public class GeneticAlgorithm {
materialRequirementService
=
_materialRequirementService
;
_sceneService
=
sceneService
;
sceneId
=
_sceneId
;
materialIds
=
_materialIds
;
}
public
void
Init
(
double
[]
customWeights
,
boolean
pureNSGAIIMode
)
{
...
...
@@ -127,7 +131,9 @@ public class GeneticAlgorithm {
if
(
population
.
size
()<
param
.
getTournamentSize
())
{
best
.
setBaseTime
(
param
.
getBaseTime
());
best
.
setOrderMaterials
(
orderMaterials
);
// best.setOrderMaterials(orderMaterials);
best
.
setMaterialIds
(
materialIds
);
best
.
setMaterials
(
null
);
// best.setOperatRel(_entryRel);
if
(
best
.
getInitMachines
()==
null
)
...
...
@@ -267,7 +273,8 @@ public class GeneticAlgorithm {
FileHelper
.
writeLogFile
(
"迭代进化-----------结束-------"
);
best
.
setBaseTime
(
param
.
getBaseTime
());
best
.
setOrderMaterials
(
orderMaterials
);
best
.
setMaterialIds
(
materialIds
);
best
.
setMaterials
(
null
);
// best.setOperatRel(_entryRel);
if
(
best
.
getInitMachines
()==
null
)
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
f0fc8121
...
...
@@ -499,6 +499,22 @@ if(finishedOrder==null||finishedOrder.size()==0)
// _globalParam.set_smoothChangeOver(false);
CopyOnWriteArrayList
<
ScheduleResultDetail
>
geneDetails
=
new
CopyOnWriteArrayList
<>();
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
)
{
int
earliestStartTimeold
=
earliestStartTime
;
if
(
_globalParam
.
is_smoothChangeOver
())
{
...
...
@@ -518,6 +534,10 @@ if(finishedOrder==null||finishedOrder.size()==0)
earliestStartTime
=
bomtime
;
}
}
if
(
machine
.
getId
()==
2063
)
{
int
i
=
0
;
}
...
...
src/main/java/com/aps/service/Algorithm/MachineCalculator.java
View file @
f0fc8121
...
...
@@ -519,6 +519,13 @@ public class MachineCalculator {
// 计算有效时间
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
effectiveend
=
timeSegments2
.
get
(
timeSegments2
.
size
()-
1
).
getEnd
();
...
...
@@ -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
;
if
(!
machine
.
getAvailability
().
isEmpty
())
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
f0fc8121
...
...
@@ -831,7 +831,7 @@ if(headers1==null)
if
(
MaterialRequirements
!=
null
&&
MaterialRequirements
.
size
()>
0
)
{
for
(
OrderMaterialRequirement
orderMaterial
:
MaterialRequirements
)
{
double
allneeded
=
parentQuantity
*
orderMaterial
.
getRequiredQuantity
();
double
allneeded
=
orderMaterial
.
getRequiredQuantity
();
double
needed
=
allneeded
;
...
...
@@ -1276,7 +1276,7 @@ if(headers1==null)
Long
CkeckLeadTime
=
material
.
getCkeckLeadTime
();
List
<
MaterialSupply
>
sortedInTransit
=
material
.
getInTransit
().
stream
()
.
filter
(
t
->
t
.
getQuantity
()
>
0
&&
t
.
getArrivalTime
().
compareTo
(
earliestStartTime
)<=
0
)
.
sorted
(
Comparator
.
comparing
(
MaterialSupply:
:
getArrivalTime
))
.
sorted
(
Comparator
.
comparing
(
MaterialSupply:
:
getArrivalTime
)
.
reversed
()
)
.
collect
(
Collectors
.
toList
());
for
(
MaterialSupply
supply
:
sortedInTransit
)
{
...
...
@@ -1417,7 +1417,7 @@ if(headers1==null)
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
);
if
(
materials
==
null
)
{
...
...
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
f0fc8121
...
...
@@ -23,6 +23,13 @@ import java.util.stream.IntStream;
*/
public
class
ScheduleOperationService
{
private
MaterialRequirementService
materialRequirementService
;
public
ScheduleOperationService
(
MaterialRequirementService
_materialRequirementService
)
{
materialRequirementService
=
_materialRequirementService
;
}
/**
* 移动工序方法
* @param chromosome 染色体对象
...
...
@@ -1214,7 +1221,7 @@ if(targetOp.getSequence()>1) {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getInitMachines
(),
Machine
.
class
)
);
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
.
getResult
().
clear
();
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
f0fc8121
This diff is collapsed.
Click to expand it.
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
f0fc8121
...
...
@@ -39,7 +39,9 @@ public class PlanResultServiceTest {
// TestSortService sortService=new TestSortService();
// sortService.test1();
// nsgaiiUtils.Test();
planResultService
.
execute2
(
"18E5F8BE09B14EAE822651BFEF100900"
);
// planResultService.execute2("1BC8FFD1A7D54AE7AA75D2CBC7C08080");
// planResultService.execute2("00E0C5D3E4AD4F36B56C39395906618D");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
...
...
@@ -47,7 +49,7 @@ public class PlanResultServiceTest {
// opids.add(7);
// planResultService.Move("27065EA0ECD14A81B7FAAFEF52273F93",opids,t,1265l,0);
// planResultService.Redecode("27065EA0ECD14A81B7FAAFEF52273F93");
// planResultService.Redecode("CA71321FE55B4437A3900315692F9220
");
planResultService
.
Redecode
(
"00E0C5D3E4AD4F36B56C39395906618D
"
);
// planResultService.Drag("27065EA0ECD14A81B7FAAFEF52273F93",opids,6,false,0l);
// MaintenanceWindow maintenanceWindow=new MaintenanceWindow();
// 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