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
eb9004a2
Commit
eb9004a2
authored
Jan 20, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
换型,拖动
parent
18420541
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
742 additions
and
141 deletions
+742
-141
Entry.java
src/main/java/com/aps/entity/basic/Entry.java
+3
-1
GlobalParam.java
src/main/java/com/aps/entity/basic/GlobalParam.java
+5
-1
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+13
-12
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+172
-79
GeneticOperations.java
...ain/java/com/aps/service/Algorithm/GeneticOperations.java
+1
-1
MachineCalculator.java
...ain/java/com/aps/service/Algorithm/MachineCalculator.java
+325
-28
NSGAIIUtils.java
src/main/java/com/aps/service/Algorithm/NSGAIIUtils.java
+4
-0
RoutingDataService.java
...in/java/com/aps/service/Algorithm/RoutingDataService.java
+4
-0
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+191
-14
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+19
-2
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+5
-3
No files found.
src/main/java/com/aps/entity/basic/Entry.java
View file @
eb9004a2
...
...
@@ -142,7 +142,9 @@ public class Entry {
private
BigDecimal
runtime
;
//持续时间
private
BigDecimal
singleOut
;
//单件产出
private
double
changeLineTime
;
//换模时间
private
BigDecimal
setupTime
;
private
BigDecimal
setupTime
;
//准备时间
private
int
teardownTime
;
// 收尾时间(后处理时间)
//常数时间
private
int
constTime
;
private
String
equipCode
;
//设备编码
private
String
equipName
;
//设备编码
...
...
src/main/java/com/aps/entity/basic/GlobalParam.java
View file @
eb9004a2
...
...
@@ -38,5 +38,9 @@ public class GlobalParam {
/// </summary>
private
boolean
IsOverlap
=
false
;
private
boolean
_smoothSetup
=
false
;
// 默认true,不占用设备时长
private
boolean
_smoothSetup
=
false
;
// 设置时间平滑 工序的前处理是否提前
private
boolean
_smoothChangeOver
=
true
;
// 默认true,设置时间 是否考虑换型时间
private
boolean
_smoothChangeOverInWeek
=
true
;
// 默认true,后台任务设置 休息时间是否换型
}
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
eb9004a2
...
...
@@ -13,10 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -361,29 +358,33 @@ return population;
FileHelper
.
writeLogFile
(
String
.
format
(
" KPI---%f-------"
,
d
));
}
}
private
ExecutorService
decodeExecutor
=
Executors
.
newFixedThreadPool
(
Runtime
.
getRuntime
().
availableProcessors
()
*
2
);
//private ExecutorService decodeExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
private
final
ExecutorService
decodeExecutor
=
new
ThreadPoolExecutor
(
Runtime
.
getRuntime
().
availableProcessors
()
-
1
,
// 核心线程数=CPU-1,无切换开销
Runtime
.
getRuntime
().
availableProcessors
()
-
1
,
// 最大线程数=核心数
0L
,
TimeUnit
.
MILLISECONDS
,
new
ArrayBlockingQueue
<>(
200
),
// 有界队列,避免内存溢出
new
ThreadPoolExecutor
.
CallerRunsPolicy
()
// 任务满了主线程执行,不丢失任务
);
private
void
Chromosomedecode
(
ScheduleParams
param
,
List
<
Entry
>
allOperations
,
List
<
GlobalOperationInfo
>
globalOpList
,
List
<
Chromosome
>
population
)
{
FileHelper
.
writeLogFile
(
"解码---------------"
+
population
.
size
()
);
GeneticDecoder
decoder
=
new
GeneticDecoder
(
_GlobalParam
,
param
.
getBaseTime
(),
machines
,
orders
,
materials
,
machineScheduler
,
orderMaterials
);
boolean
ismore
=
true
;
if
(
ismore
)
{
CompletableFuture
.
allOf
(
population
.
stream
()
.
map
(
chromosome
->
CompletableFuture
.
runAsync
(()
->
decode
(
decoder
,
chromosome
,
param
,
allOperations
,
globalOpList
),
decodeExecutor
))
.
toArray
(
CompletableFuture
[]::
new
))
.
join
();
if
(
1
==
2
)
{
}
else
{
if
(
population
!=
null
&&
population
.
size
()
>
0
)
{
population
.
parallelStream
().
forEach
(
chromosome
->
{
decode
(
decoder
,
chromosome
,
param
,
allOperations
,
globalOpList
);
});
}
}
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
eb9004a2
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/Algorithm/GeneticOperations.java
View file @
eb9004a2
...
...
@@ -37,7 +37,7 @@ public class GeneticOperations {
if
(
population
==
null
||
population
.
isEmpty
())
{
return
new
ArrayList
<>();
}
int
populationSize
=
population
.
size
();
int
populationSize
=
population
.
size
()
>
100
?((
int
)(
population
.
size
()*
0.8
)):
population
.
size
()
;
// 预计算需要选中的个体数量,避免动态判断
int
needSelectCount
=
populationSize
-
Math
.
max
(
1
,
Math
.
min
(
tournamentSize
,
populationSize
));
List
<
Chromosome
>
selected
=
new
ArrayList
<>(
needSelectCount
);
// 预初始化容量
...
...
src/main/java/com/aps/service/Algorithm/MachineCalculator.java
View file @
eb9004a2
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/Algorithm/NSGAIIUtils.java
View file @
eb9004a2
package
com
.
aps
.
service
.
Algorithm
;
import
com.aps.common.util.FileHelper
;
import
com.aps.entity.Algorithm.Chromosome
;
import
com.aps.entity.Algorithm.ObjectiveWeights
;
...
...
@@ -48,7 +49,10 @@ public class NSGAIIUtils {
* 并行快速非支配排序(大规模种群提速50%+)
*/
public
List
<
List
<
Chromosome
>>
parallelFastNonDominatedSort
(
List
<
Chromosome
>
population
)
{
int
popSize
=
population
.
size
();
FileHelper
.
writeLogFile
(
"非支配排序---------------"
+
popSize
);
List
<
List
<
Chromosome
>>
fronts
=
new
ArrayList
<>();
// 步骤1:预处理 - 计算归一化目标值和加权目标值
...
...
src/main/java/com/aps/service/Algorithm/RoutingDataService.java
View file @
eb9004a2
...
...
@@ -213,7 +213,10 @@ public class RoutingDataService {
entry
.
setEquipTypeCode
(
op
.
getEquipTypeCode
());
entry
.
setRuntime
(
op
.
getRuntime
());
entry
.
setSingleOut
(
op
.
getSingleOut
());
//生产准备
entry
.
setSetupTime
(
op
.
getSetupTime
());
//后处理
entry
.
setTeardownTime
(
op
.
getPostprocessingTime
());
entry
.
setConstTime
(
op
.
getConstTime
());
entry
.
setOrderId
(
op
.
getOrderId
());
entry
.
setOrderCode
(
op
.
getOrderCode
());
...
...
@@ -248,6 +251,7 @@ public class RoutingDataService {
machineIds
.
replace
(
e
.
getEquipId
(),
totalprocessTime
);
}
}
else
{
//大概记录要用到的设备的加工时间,用于生成设备日历
machineIds
.
put
(
e
.
getEquipId
(),
totalprocessTime
);
}
...
...
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
eb9004a2
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
eb9004a2
...
...
@@ -540,6 +540,23 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
return
chromosome
;
}
public
Chromosome
Drag
(
String
SceneId
,
List
<
Integer
>
opId
,
int
targetopId
,
Boolean
isfront
,
Long
newMachineId
)
{
GlobalParam
globalParam
=
new
GlobalParam
();
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
// WriteScheduleSummary(chromosome);
ScheduleOperation
.
dragOperation
(
chromosome
,
opId
,
targetopId
,
isfront
,
newMachineId
,
globalParam
);
// WriteScheduleSummary(chromosome);
_sceneService
.
saveChromosomeToFile
(
chromosome
,
SceneId
);
return
chromosome
;
}
public
Chromosome
Move
(
String
SceneId
,
List
<
Integer
>
opId
,
LocalDateTime
newStartTime
,
Long
newMachineId
,
int
lockStartTime
)
{
...
...
@@ -583,11 +600,11 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
{
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
WriteScheduleSummary
(
chromosome
);
//
WriteScheduleSummary(chromosome);
GlobalParam
globalParam
=
new
GlobalParam
();
ScheduleOperation
.
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
WriteScheduleSummary
(
chromosome
);
//
WriteScheduleSummary(chromosome);
}
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
eb9004a2
...
...
@@ -37,14 +37,16 @@ public class PlanResultServiceTest {
// NSGAIIUtils nsgaiiUtils=new NSGAIIUtils();
// nsgaiiUtils.Test();
planResultService
.
execute2
(
"C5FB5EF2A7334A0A92F826F4937E100
8"
);
// planResultService.execute2("FFAC5AA2E0B943D292933B28BDAB906
8");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
//
List<Integer> opids=new ArrayList<>();//BCA6FA43FFA444D3952CF8F6E1EA291B
// opids.add(9
);
List
<
Integer
>
opids
=
new
ArrayList
<>();
//BCA6FA43FFA444D3952CF8F6E1EA291B
opids
.
add
(
7
);
// planResultService.Move("27065EA0ECD14A81B7FAAFEF52273F93",opids,t,1265l,0);
// planResultService.Redecode("27065EA0ECD14A81B7FAAFEF52273F93");
// planResultService.Redecode("CA71321FE55B4437A3900315692F9220");
planResultService
.
Drag
(
"27065EA0ECD14A81B7FAAFEF52273F93"
,
opids
,
6
,
false
,
0
l
);
// MaintenanceWindow maintenanceWindow=new MaintenanceWindow();
// maintenanceWindow.setStartTime(LocalDateTime.of(2025, 10, 21, 0, 0, 0));
// maintenanceWindow.setEndTime(LocalDateTime.of(2025, 10, 31, 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