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
4cad6053
Commit
4cad6053
authored
Sep 20, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MP
parent
be4b7722
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
55 deletions
+55
-55
MacroPlannerOptimizer.java
...main/java/com/aps/macroplanner/MacroPlannerOptimizer.java
+3
-3
ResultWriter.java
src/main/java/com/aps/macroplanner/output/ResultWriter.java
+52
-52
No files found.
src/main/java/com/aps/macroplanner/MacroPlannerOptimizer.java
View file @
4cad6053
...
...
@@ -201,7 +201,7 @@ public class MacroPlannerOptimizer {
writeLog
(
" [OK] 目标函数创建完成"
);
// 4. 导出 LP 模型文件
//
exportLpModel();
exportLpModel
();
writeLog
(
"\n模型统计: 变量="
+
model
.
getSolver
().
numVariables
()
+
", 约束="
+
model
.
getSolver
().
numConstraints
()
+
"\n"
);
...
...
@@ -442,7 +442,7 @@ public class MacroPlannerOptimizer {
l3
.
addKPI
(
"供应目标偏差"
,
model
.
getTotalSupplyTarget
(),
w
.
getSupplyTargetWeight
());
l3
.
addKPI
(
"销售优先级"
,
model
.
getTotalSalesDemandPriority
(),
w
.
getSalesDemandPriorityWeight
(),
true
);
// 负系数 = 最大化
//
levels.add(l3);
levels
.
add
(
l3
);
// === Level 4: 软约束 (允许 10% 退化, slack=10%) ===
StrategyLevel
l4
=
new
StrategyLevel
(
4
,
"软约束"
,
0.10
);
...
...
@@ -450,7 +450,7 @@ public class MacroPlannerOptimizer {
l4
.
addKPI
(
"欠库存"
,
model
.
getTotalMinInventoryLevel
(),
w
.
getMinInventoryLevelWeight
());
l4
.
addKPI
(
"最小供应不足"
,
model
.
getTotalMinSupply
(),
w
.
getMinSupplyWeight
());
l4
.
addKPI
(
"最大供应超出"
,
model
.
getTotalMaxSupply
(),
w
.
getMaxSupplyWeight
());
//
levels.add(l4);
levels
.
add
(
l4
);
return
levels
;
}
...
...
src/main/java/com/aps/macroplanner/output/ResultWriter.java
View file @
4cad6053
...
...
@@ -234,59 +234,59 @@ public class ResultWriter {
writeLog
(
"writeOperationDemands"
);
List
<
OperationDemandResult
>
opDemands
=
buildOperationDemandResults
();
parquetUtil
.
write
(
opDemands
,
getOptimizationOperationDemand
(
sceneId
),
OperationDemandResult
.
class
);
try
{
File
file
=
getOptimizationFile
(
sceneId
);
File
tempFile
=
new
File
(
file
.
getParentFile
(),
file
.
getName
()
+
".tmp"
);
if
(
useCompression
)
{
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
tempFile
);
GZIPOutputStream
gzos
=
new
GZIPOutputStream
(
fos
))
{
objectMapper
.
writeValue
(
gzos
,
result
);
}
}
else
{
objectMapper
.
writeValue
(
tempFile
,
result
);
}
if
(
tempFile
.
length
()
==
0
)
{
logger
.
error
(
"写入的临时文件为空: {}"
,
tempFile
.
getAbsolutePath
());
Files
.
deleteIfExists
(
tempFile
.
toPath
());
return
false
;
}
if
(
useCompression
)
{
try
(
FileInputStream
fis
=
new
FileInputStream
(
tempFile
);
GZIPInputStream
gzis
=
new
GZIPInputStream
(
fis
))
{
OptimizationResult
verifyChromosome
=
objectMapper
.
readValue
(
gzis
,
OptimizationResult
.
class
);
if
(
verifyChromosome
==
null
)
{
throw
new
IOException
(
"验证读取失败"
);
}
}
}
else
{
try
{
OptimizationResult
verifyChromosome
=
objectMapper
.
readValue
(
tempFile
,
OptimizationResult
.
class
);
if
(
verifyChromosome
==
null
)
{
throw
new
IOException
(
"验证读取失败"
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"验证染色体文件内容失败,文件: {}"
,
tempFile
.
getAbsolutePath
(),
e
);
Files
.
deleteIfExists
(
tempFile
.
toPath
());
return
false
;
}
}
if
(
file
.
exists
())
{
Files
.
deleteIfExists
(
file
.
toPath
());
}
Files
.
move
(
tempFile
.
toPath
(),
file
.
toPath
());
logger
.
info
(
"保存成功,场景ID: {}, 文件: {}"
,
sceneId
,
file
.
getAbsolutePath
());
return
true
;
// try {
//
// File file = getOptimizationFile(sceneId);
// File tempFile = new File(file.getParentFile(), file.getName() + ".tmp");
//
// if (useCompression) {
// try (FileOutputStream fos = new FileOutputStream(tempFile);
// GZIPOutputStream gzos = new GZIPOutputStream(fos)) {
// objectMapper.writeValue(gzos, result);
// }
// } else {
// objectMapper.writeValue(tempFile, result);
// }
//
// if (tempFile.length() == 0) {
// logger.error("写入的临时文件为空: {}", tempFile.getAbsolutePath());
// Files.deleteIfExists(tempFile.toPath());
// return false;
// }
//
// if (useCompression) {
// try (FileInputStream fis = new FileInputStream(tempFile);
// GZIPInputStream gzis = new GZIPInputStream(fis)) {
// OptimizationResult verifyChromosome = objectMapper.readValue(gzis, OptimizationResult.class);
// if (verifyChromosome == null) {
// throw new IOException("验证读取失败");
// }
// }
// } else {
// try {
// OptimizationResult verifyChromosome = objectMapper.readValue(tempFile, OptimizationResult.class);
// if (verifyChromosome == null) {
// throw new IOException("验证读取失败");
// }
// } catch (Exception e) {
// logger.error("验证染色体文件内容失败,文件: {}", tempFile.getAbsolutePath(), e);
// Files.deleteIfExists(tempFile.toPath());
// return false;
// }
// }
//
// if (file.exists()) {
// Files.deleteIfExists(file.toPath());
// }
// Files.move(tempFile.toPath(), file.toPath());
//
// logger.info("保存成功,场景ID: {}, 文件: {}", sceneId, file.getAbsolutePath());
// return true;
// } catch (Exception e) {
// logger.error("保存文件失败,场景ID: " + sceneId, e);
// return false;
// }
}
catch
(
Exception
e
)
{
logger
.
error
(
"保存文件失败,场景ID: "
+
sceneId
,
e
);
return
false
;
}
}
catch
(
IOException
ex
)
{
logger
.
error
(
"保存文件失败,场景ID: "
+
sceneId
,
ex
);
return
false
;
...
...
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