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
cd22f5cc
Commit
cd22f5cc
authored
Nov 21, 2025
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加全局变量类
parent
0cfb29ea
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
GlobalParam.java
src/main/java/com/aps/entity/basic/GlobalParam.java
+25
-0
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+14
-0
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+66
-0
No files found.
src/main/java/com/aps/entity/basic/GlobalParam.java
0 → 100644
View file @
cd22f5cc
package
com
.
aps
.
entity
.
basic
;
import
lombok.Data
;
/**
* 作者:佟礼
* 时间:2025-11-21
*/
@Data
public
class
GlobalParam
{
/// <summary>
/// 是否可以打破优先级
/// </summary>
public
static
boolean
IsBreakPriority
=
false
;
/// <summary>
/// 是否多台设备
/// </summary>
public
static
boolean
IsMultipleMachine
=
false
;
/// <summary>
/// 是否重叠
/// </summary>
public
static
boolean
IsOverlap
=
false
;
}
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
0 → 100644
View file @
cd22f5cc
package
com
.
aps
.
service
.
Algorithm
;
import
com.aps.entity.basic.ScheduleChromosome
;
/**
* 作者:佟礼
* 时间:2025-11-21
*/
public
class
GeneticAlgorithm
{
public
void
Run
()
{
System
.
out
.
println
(
""
);
}
}
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
cd22f5cc
...
...
@@ -90,6 +90,72 @@ public class PlanResultService {
}
}
public
List
<
ScheduleChromosome
>
execute1
()
{
try
{
// 1. 读取数据
List
<
Machine
>
machines
=
loadData
(
"machines.json"
,
Machine
.
class
);
List
<
Product
>
products
=
loadData
(
"products.json"
,
Product
.
class
);
List
<
Order
>
orders
=
loadData
(
"orders.json"
,
Order
.
class
);
// 设置机器信息到班次中
for
(
Machine
machine
:
machines
)
{
if
(
machine
.
getShifts
()
!=
null
)
{
for
(
Shift
shift
:
machine
.
getShifts
())
{
shift
.
setMachineId
(
machine
.
getId
());
shift
.
setMachineName
(
machine
.
getName
());
}
}
// 调试:打印机器和班次信息
System
.
out
.
println
(
"Machine: "
+
machine
.
getId
()
+
", Name: "
+
machine
.
getName
());
if
(
machine
.
getShifts
()
!=
null
)
{
for
(
Shift
shift
:
machine
.
getShifts
())
{
System
.
out
.
println
(
" Shift: "
+
shift
.
getStartTime
()
+
" - "
+
shift
.
getEndTime
()
+
", Status: "
+
shift
.
getStatus
()
+
", MachineId: "
+
shift
.
getMachineId
()
+
", MachineName: "
+
shift
.
getMachineName
());
}
}
}
// 创建节假日
List
<
Holiday
>
holidays
=
Arrays
.
asList
(
new
Holiday
(
LocalDateTime
.
of
(
2025
,
10
,
1
,
0
,
0
),
LocalDateTime
.
of
(
2025
,
10
,
7
,
23
,
59
))
);
// 将节假日添加到所有设备中
addHolidaysToAllMachines
(
machines
,
holidays
);
// 3. 创建调度服务
MachineSchedulerService
machineScheduler
=
new
MachineSchedulerService
(
holidays
,
LocalDateTime
.
of
(
2025
,
10
,
1
,
0
,
0
,
0
));
// 4. 初始化机器时间线
for
(
Machine
machine
:
machines
)
{
MachineTimeline
timeline
=
machineScheduler
.
getOrCreateTimeline
(
machine
);
machine
.
setAvailability
(
timeline
.
getSegments
());
}
// 5. 执行调度算法
AlgorithmScheduler7
scheduler
=
new
AlgorithmScheduler7
(
products
,
machines
,
orders
,
machineScheduler
);
List
<
ScheduleChromosome
>
scheduleChromosomes
=
scheduler
.
RunAll
();
// 对调度结果按照 fitness 由高到低排序
scheduleChromosomes
.
sort
((
c1
,
c2
)
->
Double
.
compare
(
c2
.
getFitness
(),
c1
.
getFitness
()));
// 为每个 ScheduleChromosome 分配场景ID(基于排序后的位置)
for
(
int
i
=
0
;
i
<
scheduleChromosomes
.
size
();
i
++)
{
scheduleChromosomes
.
get
(
i
).
setSceneId
(
i
+
1
);
// 场景ID从1开始
}
return
scheduleChromosomes
;
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"调度执行失败"
,
e
);
}
}
/**
* 加载数据,优先从上传文件夹加载,如果不存在则从resources加载
*
...
...
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