Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8cdcaaa1
authored
Jun 28, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(project-dispatch): 算法添加真实路网时间矩阵
1 parent
05cfb647
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
13 deletions
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/DispatchConstraintProvider.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/pojo/Location.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/DispatchServiceImpl.java
project-dispatch/src/main/resources/data/pathTimeMatrix.csv
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/DispatchConstraintProvider.java
View file @
8cdcaaa
...
...
@@ -56,7 +56,7 @@ public class DispatchConstraintProvider implements ConstraintProvider {
protected
Constraint
technicianBalance
(
ConstraintFactory
factory
)
{
// 会导致剩余单子集中?
return
factory
.
forEach
(
Technician
.
class
).
filter
(
technician
->
technician
.
getOffWorkTime
()
>
1
4
40
)
return
factory
.
forEach
(
Technician
.
class
).
filter
(
technician
->
technician
.
getOffWorkTime
()
>
1
1
40
)
.
penalizeLong
(
HardSoftLongScore
.
ONE_HARD
,
technician
->
(
long
)
Math
.
ceil
(
technician
.
getOffWorkTime
()
/
1440
f
))
.
asConstraint
(
"订单均分"
);
...
...
@@ -64,7 +64,7 @@ public class DispatchConstraintProvider implements ConstraintProvider {
protected
Constraint
technicianBalance2
(
ConstraintFactory
factory
)
{
// 单量不能过少 FIXME
return
factory
.
forEach
(
Technician
.
class
).
filter
(
technician
->
technician
.
getOffWorkTime
()
<=
114
0
)
return
factory
.
forEach
(
Technician
.
class
).
filter
(
technician
->
technician
.
getOffWorkTime
()
<=
96
0
)
.
penalizeLong
(
HardSoftLongScore
.
ONE_HARD
,
technician
->
1
)
.
asConstraint
(
"订单均分2"
);
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/pojo/Location.java
View file @
8cdcaaa
...
...
@@ -41,16 +41,15 @@ public class Location {
return
distanceMap
.
get
(
location
);
}
/**
* time to the given location in minutes.
* FIXME 这里简化处理没有用时间矩阵 时间=距离/100
*
* @param location other location
* @return time in minutes
*/
public
int
getPathTimeTo
(
Location
location
)
{
return
(
int
)(
distanceMap
.
get
(
location
)/
100
);
}
/**
* time to the given location in minutes.
*
* @param location other location
* @return time in minutes
*/
public
int
getPathTimeTo
(
Location
location
)
{
return
distanceTimeMap
.
get
(
location
).
intValue
();
}
// ************************************************************************
// Complex methods
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/DispatchServiceImpl.java
View file @
8cdcaaa
...
...
@@ -59,7 +59,7 @@ public class DispatchServiceImpl implements DispatchService {
@Override
public
Result
<?>
manualDispatch
()
throws
UncheckedIOException
,
FileNotFoundException
{
logger
.
info
(
"
%s
"
,
"invoke manualDispatch"
);
logger
.
info
(
"
{}
"
,
"invoke manualDispatch"
);
// 创建解决方案对象
Map
<
Integer
,
String
>
customerIndexMap
=
loadCustomerIndex
();
...
...
@@ -248,6 +248,23 @@ public class DispatchServiceImpl implements DispatchService {
}
// 初始化时间矩阵
List
<
String
>
pathTimeMatrixlines
=
IOUtils
.
readLines
(
new
FileInputStream
(
"data/pathTimeMatrix.csv"
),
"utf-8"
);
long
[][]
pathTimeMatrix
=
new
long
[
customerIndexMap
.
keySet
().
size
()
+
1
][
customerIndexMap
.
keySet
().
size
()
+
1
];
for
(
int
i
=
0
;
i
<
pathTimeMatrixlines
.
size
();
i
++)
{
String
line
=
pathTimeMatrixlines
.
get
(
i
);
String
[]
temps
=
line
.
split
(
","
);
for
(
int
j
=
0
;
j
<
temps
.
length
;
j
++)
{
// 秒转分钟
pathTimeMatrix
[
i
][
j
]
=
(
long
)
(
Math
.
round
(
Float
.
parseFloat
(
temps
[
j
])
/
60
));
}
}
for
(
int
i
=
0
;
i
<
pathTimeMatrix
.
length
;
i
++)
{
Location
locationi
=
locationIndex
.
get
(
i
+
1
);
for
(
int
j
=
0
;
j
<
pathTimeMatrix
[
i
].
length
;
j
++)
{
Location
locationj
=
locationIndex
.
get
(
j
+
1
);
locationi
.
getDistanceTimeMap
().
put
(
locationj
,
pathTimeMatrix
[
i
][
j
]);
}
}
// 初始化订单服务窗
List
<
String
>
customerWindowslines
=
IOUtils
.
readLines
(
new
FileInputStream
(
"data/customerWindows.csv"
),
"utf-8"
);
...
...
project-dispatch/src/main/resources/data/pathTimeMatrix.csv
0 → 100644
View file @
8cdcaaa
This diff could not be displayed because it is too large.
Write
Preview
Markdown
is supported
Attach a file
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 post a comment