Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Conversion
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vladislav Kiselev
Conversion
Commits
eaef1dcc
Commit
eaef1dcc
authored
Nov 19, 2018
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Все операции с хранилищами
parent
c5d0db0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
11 deletions
+116
-11
src/inport/ConversionUtil.java
src/inport/ConversionUtil.java
+95
-8
test/conversion_0.mzn
test/conversion_0.mzn
+21
-3
No files found.
src/inport/ConversionUtil.java
View file @
eaef1dcc
...
...
@@ -39,7 +39,7 @@ public class ConversionUtil {
}
else
{
s
.
append
(
", "
);
}
s
.
append
(
(
val
+
1
)
);
s
.
append
(
val
);
}
s
.
append
(
'}'
);
return
s
.
toString
();
...
...
@@ -238,8 +238,8 @@ public class ConversionUtil {
movingObjN
.
add
(
mObjToN
.
apply
(
op
.
getMover
()));
for
(
Integer
n
:
movingObjN
)
{
arrivalOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getDestination
().
getId
(),
false
)).
add
(
i
);
departureOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
false
)).
add
(
i
);
arrivalOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getDestination
().
getId
(),
false
)).
add
(
i
+
1
);
departureOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
false
)).
add
(
i
+
1
);
}
}
else
if
(
operationTemplates
.
get
(
i
)
instanceof
MooringTemplate
)
{
MooringTemplate
op
=
(
MooringTemplate
)
operationTemplates
.
get
(
i
);
...
...
@@ -251,8 +251,8 @@ public class ConversionUtil {
movingObjN
.
add
(
mObjToN
.
apply
(
op
.
getMoorer
()));
for
(
Integer
n
:
movingObjN
)
{
arrivalOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
!
op
.
isDirect
())).
add
(
i
);
departureOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
op
.
isDirect
())).
add
(
i
);
arrivalOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
!
op
.
isDirect
())).
add
(
i
+
1
);
departureOp
.
get
(
n
).
get
(
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
op
.
isDirect
())).
add
(
i
+
1
);
}
}
}
...
...
@@ -316,13 +316,13 @@ public class ConversionUtil {
}
writeArray
(
writer
,
"final_m_obj_loc"
,
finalStates
,
(
Integer
p
)
->
p
+
1
);
}
{
// Наличие всех ресурсов на месте.
// TODO
покрывается "Конфликтующими операциями"
.
{
// Наличие всех ресурсов на месте
, в том числе и самого корабля
.
// TODO
ресурсы покрываются "Конфликтующими операциями" (кроме наличия корабля на месте)
.
ArrayList
<
Set
<
Integer
>>
operationsResources
=
new
ArrayList
<>();
ArrayList
<
Integer
>
operationsStartLoc
=
integerArray
(
operationTemplates
.
size
(),
0
);
for
(
int
i
=
0
;
i
<
operationTemplates
.
size
();
i
++)
{
operationsResources
.
add
(
new
TreeSet
<>());
if
(
operationTemplates
.
get
(
i
)
instanceof
MovingTemplate
)
{
if
(
operationTemplates
.
get
(
i
)
instanceof
MovingTemplate
)
{
// Перемещение.
MovingTemplate
op
=
(
MovingTemplate
)
operationTemplates
.
get
(
i
);
Set
<
Integer
>
s
=
new
TreeSet
<>();
...
...
@@ -332,6 +332,26 @@ public class ConversionUtil {
}
operationsResources
.
set
(
i
,
s
);
operationsStartLoc
.
set
(
i
,
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
false
)
+
1
);
}
else
if
(
operationTemplates
.
get
(
i
)
instanceof
MooringTemplate
)
{
// Швартовка.
MooringTemplate
op
=
(
MooringTemplate
)
operationTemplates
.
get
(
i
);
Set
<
Integer
>
s
=
new
TreeSet
<>();
s
.
add
(
mObjToN
.
apply
(
op
.
getMoorer
())
+
1
);
for
(
MovingObject
obj
:
op
.
getResources
())
{
s
.
add
(
mObjToN
.
apply
(
obj
)
+
1
);
}
operationsResources
.
set
(
i
,
s
);
operationsStartLoc
.
set
(
i
,
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
!
op
.
isDirect
())
+
1
);
}
else
if
(
operationTemplates
.
get
(
i
)
instanceof
LoadingTemplate
)
{
// Погрузка.
LoadingTemplate
op
=
(
LoadingTemplate
)
operationTemplates
.
get
(
i
);
Set
<
Integer
>
s
=
new
TreeSet
<>();
s
.
add
(
mObjToN
.
apply
(
op
.
getLoader
())
+
1
);
// TODO ресурсы у операции погрузки.
operationsResources
.
set
(
i
,
s
);
operationsStartLoc
.
set
(
i
,
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
true
)
+
1
);
}
// TODO швартовка, погрузка.
}
...
...
@@ -426,6 +446,73 @@ public class ConversionUtil {
write2DArrayOfInt
(
writer
,
"initial_storage_vol"
,
initialStorageVol
);
write2DArrayOfInt
(
writer
,
"final_storage_vol"
,
finalStorageVol
);
}
{
// Потоки грузов.
ArrayList
<
ArrayList
<
ArrayList
<
Integer
>>>
cargoFlows
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
nObjWithStorage
;
i
++)
{
cargoFlows
.
add
(
new
ArrayList
<>());
for
(
int
j
=
0
;
j
<
n_intervals
+
2
;
j
++)
{
cargoFlows
.
get
(
i
).
add
(
new
ArrayList
<>());
for
(
int
k
=
0
;
k
<
cargoes
.
size
();
k
++)
{
cargoFlows
.
get
(
i
).
get
(
j
).
add
(
0
);
}
}
}
for
(
CargoFlow
flow
:
task
.
getCargoFlows
())
{
int
storageN
=
storNById
.
get
(
flow
.
getStorage
().
getId
());
int
cargoN
=
cargoNById
.
get
(
flow
.
getCargo
().
getId
());
for
(
int
i
=
1
;
i
<
n_intervals
+
2
;
i
++)
{
cargoFlows
.
get
(
storageN
+
movingObjects
.
size
()).
get
(
i
).
set
(
cargoN
,
(
int
)
flow
.
getCurrentValue
(
i
));
}
}
writer
.
write
(
"cargo_flows = array3d(1..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types, ["
);
boolean
isFirst
=
true
;
for
(
int
i
=
0
;
i
<
nObjWithStorage
;
i
++)
{
for
(
int
j
=
0
;
j
<
n_intervals
+
2
;
j
++)
{
for
(
int
k
=
0
;
k
<
cargoes
.
size
();
k
++)
{
if
(
isFirst
)
{
isFirst
=
false
;
}
else
{
writer
.
write
(
", "
);
}
writer
.
write
(
cargoFlows
.
get
(
i
).
get
(
j
).
get
(
k
).
toString
());
}
}
}
writer
.
write
(
"]);\n\n"
);
}
{
// Грузовые операции со всеми хранилищами.
ArrayList
<
ArrayList
<
ArrayList
<
Integer
>>>
involvedOperations
=
new
ArrayList
<>();
ArrayList
<
Integer
>
loadingOpDelta
=
new
ArrayList
<>();
ArrayList
<
Integer
>
loadingOpN
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
nObjWithStorage
;
i
++)
{
involvedOperations
.
add
(
new
ArrayList
<>());
for
(
int
j
=
0
;
j
<
cargoes
.
size
();
j
++)
{
involvedOperations
.
get
(
i
).
add
(
new
ArrayList
<>());
}
}
for
(
int
i
=
0
;
i
<
operationTemplates
.
size
();
i
++)
{
if
(
operationTemplates
.
get
(
i
)
instanceof
LoadingTemplate
)
{
LoadingTemplate
op
=
(
LoadingTemplate
)
operationTemplates
.
get
(
i
);
int
storageN
=
storNById
.
get
(
op
.
getStorage
().
getId
());
int
shipN
=
mObjToN
.
apply
(
op
.
getLoader
());
int
cargoN
=
0
;
// TODO в TaskCase пока не реализовано, пересмотреть.
loadingOpDelta
.
add
(-(
int
)
op
.
getIntensity
());
loadingOpN
.
add
(
i
);
involvedOperations
.
get
(
storageN
+
movingObjects
.
size
()).
get
(
cargoN
).
add
(
loadingOpDelta
.
size
());
loadingOpDelta
.
add
((
int
)
op
.
getIntensity
());
loadingOpN
.
add
(
i
);
involvedOperations
.
get
(
shipN
).
get
(
cargoN
).
add
(
loadingOpDelta
.
size
());
}
}
writer
.
write
(
"n_loading_op = "
+
loadingOpDelta
.
size
()
+
";\n"
);
write2DArrayOfSet
(
writer
,
"involved_operations"
,
involvedOperations
);
writeArray
(
writer
,
"loading_op_delta"
,
loadingOpDelta
);
writeArray
(
writer
,
"loading_op_n"
,
loadingOpN
);
}
}
}
...
...
test/conversion_0.mzn
View file @
eaef1dcc
...
...
@@ -138,10 +138,27 @@ array [1..n_obj_with_storage, 1..n_cargo_types] of int : final_storage_vol;
constraint
forall
(
storage
in
1
..
n_obj_with_storage
,
cargo
in
1
..
n_cargo_types
)
(
(
storage_used_volume
[
storage
,
0
,
cargo
]
==
initial_storage_vol
[
storage
,
cargo
])
/\
if
final_storage_vol
[
storage
,
cargo
]
>=
0
then
(
if
final_storage_vol
[
storage
,
cargo
]
>=
0
then
(
storage_used_volume
[
storage
,
(
n_intervals
+
1
),
cargo
]
==
final_storage_vol
[
storage
,
cargo
])
else
true
endif
endif
)
);
% Изменение грузов в хранилищах.
array
[
1
..
n_obj_with_storage
,
0
..
(
n_intervals
+
1
),
1
..
n_cargo_types
]
of
int
:
cargo_flows
;
int
:
n_loading_op
;
array
[
1
..
n_obj_with_storage
,
1
..
n_cargo_types
]
of
set
of
1
..
n_loading_op
:
involved_operations
;
array
[
1
..
n_loading_op
]
of
int
:
loading_op_delta
;
array
[
1
..
n_loading_op
]
of
1
..
n_operations
:
loading_op_n
;
% Номера среди общего списка операций.
constraint
forall
(
storage
in
1
..
n_obj_with_storage
,
cargo
in
1
..
n_cargo_types
,
t
in
1
..
(
n_intervals
+
1
))
(
storage_used_volume
[
storage
,
t
,
cargo
]
=
storage_used_volume
[
storage
,
t
-
1
,
cargo
]
+
cargo_flows
[
storage
,
t
,
cargo
]
+
sum
(
inv_op
in
involved_operations
[
storage
,
cargo
])
(
loading_op_delta
[
inv_op
]
*
op_status
[
loading_op_n
[
inv_op
],
t
]
)
);
% Критерий оптимизации
...
...
@@ -164,5 +181,6 @@ output [show(sum(is_not_terminated)), "\n",
"op_start = "
,
show
(
op_start
),
"\n\n"
,
"arrival_op = "
,
show
(
arrival_op
),
"\n\n"
,
"departure_op = "
,
show
(
departure_op
),
"\n\n"
,
"is_not_terminated = "
,
show
(
is_not_terminated
),
"\n\n"
"is_not_terminated = "
,
show
(
is_not_terminated
),
"\n\n"
,
"storage_used_volume = "
,
show
(
storage_used_volume
),
"\n\n"
];
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