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
aaf66e2d
Commit
aaf66e2d
authored
Sep 08, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MP
parent
8ada9aff
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
31 deletions
+52
-31
optimization_result_1.json
mp/result/optimization_result_1.json
+1
-1
MacroPlannerDataConverterRunner.java
...com/aps/macroplanner/MacroPlannerDataConverterRunner.java
+1
-1
MacroPlannerOptimizer.java
...main/java/com/aps/macroplanner/MacroPlannerOptimizer.java
+5
-5
MultiLevelBomTestRunner.java
...in/java/com/aps/macroplanner/MultiLevelBomTestRunner.java
+19
-12
MacroPlannerDataConverter.java
.../com/aps/macroplanner/data/MacroPlannerDataConverter.java
+6
-1
MultiLevelBomTestDataBuilder.java
...m/aps/macroplanner/data/MultiLevelBomTestDataBuilder.java
+19
-10
ResultWriter.java
src/main/java/com/aps/macroplanner/output/ResultWriter.java
+1
-1
No files found.
mp/result/optimization_result_1.json
View file @
aaf66e2d
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/macroplanner/MacroPlannerDataConverterRunner.java
View file @
aaf66e2d
...
...
@@ -28,7 +28,7 @@ import org.springframework.context.ApplicationContext;
public
class
MacroPlannerDataConverterRunner
{
public
static
void
main
(
String
[]
args
)
{
String
sceneId
=
(
args
.
length
>
0
)
?
args
[
0
]
:
"
B288477F1A594DB584C87EEA77880AA3
"
;
String
sceneId
=
(
args
.
length
>
0
)
?
args
[
0
]
:
""
;
System
.
out
.
println
(
"===== MACROPLANNER DATA CONVERTER RUNNER START ====="
);
System
.
out
.
println
(
"SceneId: "
+
sceneId
);
...
...
src/main/java/com/aps/macroplanner/MacroPlannerOptimizer.java
View file @
aaf66e2d
...
...
@@ -381,11 +381,11 @@ public class MacroPlannerOptimizer {
printer
.
printHierarchicalSummary
(
levels
,
finalLevelValues
);
// 回写业务对象到JSON文件(预留)
//
ResultWriter rw = new ResultWriter(model, data, startTimeMs);
//
boolean jsonPath = rw.saveResultToFile(sceneId);
//
if (jsonPath) {
//
writeLog("\n[OK] 优化结果JSON已导出: " + jsonPath);
//
}
ResultWriter
rw
=
new
ResultWriter
(
model
,
data
,
startTimeMs
);
boolean
jsonPath
=
rw
.
saveResultToFile
(
sceneId
);
if
(
jsonPath
)
{
writeLog
(
"\n[OK] 优化结果JSON已导出: "
+
jsonPath
);
}
writeLog
(
"\n=== 分层求解完成 ==="
);
}
else
{
...
...
src/main/java/com/aps/macroplanner/MultiLevelBomTestRunner.java
View file @
aaf66e2d
...
...
@@ -46,20 +46,27 @@ public class MultiLevelBomTestRunner {
System
.
out
.
println
(
"Demand: P1=40/day, P2=30/day"
);
System
.
out
.
println
();
for
(
int
scale
:
BenchmarkDataBuilder
.
SUPPORTED_SCALES
)
{
BenchmarkDataBuilder
data
=
BenchmarkDataBuilder
.
forScale
(
scale
);
writeLog
(
"===== TEST RUNNER START "
+
scale
+
"====="
);
MultiLevelBomTestDataBuilder
builder
=
new
MultiLevelBomTestDataBuilder
();
builder
.
init
();
MacroPlannerOptimizer
optimizer
=
new
MacroPlannerOptimizer
(
builder
);
optimizer
.
buildModel
();
optimizer
.
solve
(
"bom"
);
data
.
init
();
writeLog
(
"Data loaded: "
+
data
.
getProducts
().
size
()
+
" products, "
+
data
.
getOperations
().
size
()
+
" operations"
);
MacroPlannerOptimizer
optimizer
=
new
MacroPlannerOptimizer
(
data
);
optimizer
.
buildModel
();
optimizer
.
solve
(
String
.
valueOf
(
scale
));
writeLog
(
"===== TEST RUNNER END ====="
);
}
// for (int scale : BenchmarkDataBuilder.SUPPORTED_SCALES) {
//
// BenchmarkDataBuilder data =
// BenchmarkDataBuilder.forScale(scale);
// writeLog("===== TEST RUNNER START "+scale+"=====");
//
// data.init();
// writeLog("Data loaded: " + data.getProducts().size() + " products, "
// + data.getOperations().size() + " operations");
// MacroPlannerOptimizer optimizer = new MacroPlannerOptimizer(data);
// optimizer.buildModel();
// optimizer.solve(String.valueOf(scale));
// writeLog("===== TEST RUNNER END =====");
// }
}
...
...
src/main/java/com/aps/macroplanner/data/MacroPlannerDataConverter.java
View file @
aaf66e2d
...
...
@@ -160,7 +160,12 @@ public class MacroPlannerDataConverter {
// 0. 读取时间配置, 计算 horizonEnd
// endCount = 期数 (与 periodDimension 结合决定实际天数)
ApsTimeConfig
timeConfig
=
apsTimeConfigService
.
getOne
(
new
LambdaQueryWrapper
<
ApsTimeConfig
>().
eq
(
ApsTimeConfig:
:
getMpSceneId
,
"172f545f-f94c-4143-86af-bd65e787e8e6"
));
LambdaQueryWrapper
<
ApsTimeConfig
>
wrapper
=
new
LambdaQueryWrapper
<
ApsTimeConfig
>();
if
(!
sceneId
.
isEmpty
())
{
// wrapper.eq(ApsTimeConfig::getMpSceneId,sceneId);
}
ApsTimeConfig
timeConfig
=
apsTimeConfigService
.
getOne
(
wrapper
);
ctx
.
baseTime
=
LocalDateTime
.
of
(
2026
,
9
,
28
,
0
,
0
,
0
);
// ctx.baseTime = (timeConfig != null && timeConfig.getBaseTime() != null)
// ? timeConfig.getBaseTime() : LocalDateTime.now();
...
...
src/main/java/com/aps/macroplanner/data/MultiLevelBomTestDataBuilder.java
View file @
aaf66e2d
...
...
@@ -41,8 +41,8 @@ public class MultiLevelBomTestDataBuilder extends TestDataBuilder {
protected
void
build
()
{
// === 周期: 3 天 ===
periods
.
add
(
new
Period
(
0
,
"Day1"
,
LocalDate
.
of
(
2026
,
8
,
7
)));
periods
.
add
(
new
Period
(
1
,
"Day2"
,
LocalDate
.
of
(
2026
,
8
,
8
)));
periods
.
add
(
new
Period
(
2
,
"Day3"
,
LocalDate
.
of
(
2026
,
8
,
9
)));
//
periods.add(new Period(1, "Day2", LocalDate.of(2026, 8, 8)));
//
periods.add(new Period(2, "Day3", LocalDate.of(2026, 8, 9)));
// === 产品: 成品 P1, P2 + 半成品 S1 + 原材料 R1, R2 ===
Product
prodP1
=
new
Product
(
"P1"
,
"成品P1"
);
...
...
@@ -71,13 +71,17 @@ public class MultiLevelBomTestDataBuilder extends TestDataBuilder {
// P1: 消耗 S1×2.0 + R1×3.0, 产出 P1@SP_P1
Operation
opP1
=
new
Operation
(
"OP_P1"
,
"生产P1"
,
"Unit_P1"
,
new
OperationOutput
(
prodP1
,
spP1
),
1.0
,
1.0
,
false
,
0
,
1.0
);
Operation
opP1_1
=
new
Operation
(
"OP_P1_1"
,
"生产P1"
,
"Unit_P1_1"
,
new
OperationOutput
(
prodP1
,
spP1
),
2.0
,
1.0
,
false
,
0
,
1.0
);
// P2: 消耗 S1×1.0, 产出 P2@SP_P2
Operation
opP2
=
new
Operation
(
"OP_P2"
,
"生产P2"
,
"Unit_P2"
,
new
OperationOutput
(
prodP2
,
spP2
),
1.0
,
1.0
,
false
,
0
,
1.0
);
// S1: 消耗 R2×2.0, 产出 S1@SP_Semi
//
Operation opP2 = new Operation("OP_P2", "生产P2", "Unit_P2",
//
new OperationOutput(prodP2, spP2), 1.0, 1.0, false, 0, 1.0);
//
// S1: 消耗 R2×2.0, 产出 S1@SP_Semi
Operation
opS1
=
new
Operation
(
"OP_S1"
,
"生产S1"
,
"Unit_S1"
,
new
OperationOutput
(
prodS1
,
spSemi
),
1.0
,
1.0
,
false
,
0
,
1.0
);
operations
.
addAll
(
Arrays
.
asList
(
opP1
,
opP2
,
opS1
));
// operations.addAll(Arrays.asList(opP1,opP1_1, opP2, opS1));
operations
.
addAll
(
Arrays
.
asList
(
opP1
,
opP1_1
,
opS1
));
// === 原材料采购工序 ===
Operation
opProcureR1
=
new
Operation
(
"OP_Procure_R1"
,
"采购R1"
,
"Unit_R1"
,
...
...
@@ -90,8 +94,11 @@ public class MultiLevelBomTestDataBuilder extends TestDataBuilder {
operationInputs
.
add
(
new
OperationInput
(
opP1
,
prodS1
,
spSemi
,
2.0
));
operationInputs
.
add
(
new
OperationInput
(
opP1
,
prodR1
,
spR1
,
3.0
));
operationInputs
.
add
(
new
OperationInput
(
opP1_1
,
prodS1
,
spSemi
,
2.0
));
operationInputs
.
add
(
new
OperationInput
(
opP1_1
,
prodR1
,
spR1
,
3.0
));
// === BOM 投料: P2 消耗 S1×1.0 ===
operationInputs
.
add
(
new
OperationInput
(
opP2
,
prodS1
,
spSemi
,
1.0
));
//
operationInputs.add(new OperationInput(opP2, prodS1, spSemi, 1.0));
// === BOM 投料: S1 消耗 R2×2.0 ===
operationInputs
.
add
(
new
OperationInput
(
opS1
,
prodR2
,
spR2
,
2.0
));
...
...
@@ -99,6 +106,8 @@ public class MultiLevelBomTestDataBuilder extends TestDataBuilder {
// === 设备产能: 每个设备 200h/周期 ===
for
(
Period
p
:
periods
)
{
unitPeriods
.
add
(
new
UnitPeriod
(
"Unit_P1"
,
"Unit_P1"
,
p
,
0.0
,
200.0
,
false
));
unitPeriods
.
add
(
new
UnitPeriod
(
"Unit_P1_1"
,
"Unit_P1_1"
,
p
,
0.0
,
200.0
,
false
));
unitPeriods
.
add
(
new
UnitPeriod
(
"Unit_P2"
,
"Unit_P2"
,
p
,
0.0
,
200.0
,
false
));
unitPeriods
.
add
(
new
UnitPeriod
(
"Unit_S1"
,
"Unit_S1"
,
p
,
0.0
,
200.0
,
false
));
unitPeriods
.
add
(
new
UnitPeriod
(
"Unit_R1"
,
"Unit_R1"
,
p
,
0.0
,
200.0
,
false
));
...
...
@@ -115,7 +124,7 @@ public class MultiLevelBomTestDataBuilder extends TestDataBuilder {
// === 销售需求: P1=40/周期, P2=30/周期 ===
for
(
Period
p
:
periods
)
{
salesDemands
.
add
(
new
SalesDemand
(
prodP1
,
spP1
,
p
,
40.0
,
1.0
));
salesDemands
.
add
(
new
SalesDemand
(
prodP2
,
spP2
,
p
,
30.0
,
1.0
));
//
salesDemands.add(new SalesDemand(prodP2, spP2, p, 30.0, 1.0));
}
// === 库存规格: 目标库存 ===
...
...
@@ -135,8 +144,8 @@ public class MultiLevelBomTestDataBuilder extends TestDataBuilder {
// === 供应规格: 成品+半成品各一个, 原材料各一个 ===
supplySpecs
.
add
(
new
SupplySpec
(
"Supply-P1"
,
120.0
,
80.0
,
300.0
,
true
,
Collections
.
singletonList
(
opP1
)));
supplySpecs
.
add
(
new
SupplySpec
(
"Supply-P2"
,
90.0
,
60.0
,
300.0
,
true
,
Collections
.
singletonList
(
opP2
)));
//
supplySpecs.add(new SupplySpec("Supply-P2", 90.0, 60.0, 300.0,
//
true, Collections.singletonList(opP2)));
supplySpecs
.
add
(
new
SupplySpec
(
"Supply-S1"
,
300.0
,
200.0
,
500.0
,
true
,
Collections
.
singletonList
(
opS1
)));
supplySpecs
.
add
(
new
SupplySpec
(
"Supply-R1"
,
400.0
,
200.0
,
800.0
,
...
...
src/main/java/com/aps/macroplanner/output/ResultWriter.java
View file @
aaf66e2d
...
...
@@ -245,7 +245,7 @@ public class ResultWriter {
// 元数据
result
.
setTimestamp
(
LocalDateTime
.
now
()
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
result
.
setSolver
(
"
SCIP (via Google OR-Tools)
"
);
result
.
setSolver
(
"
MP
"
);
result
.
setVersion
(
"1.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