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
963aead7
Commit
963aead7
authored
Dec 03, 2018
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Новое сведение.
parent
d9fddf86
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
192 additions
and
44 deletions
+192
-44
constraints/conversion_0.mzn
constraints/conversion_0.mzn
+2
-2
constraints/conversion_1.mzn
constraints/conversion_1.mzn
+66
-40
src/inport/ConversionUtil.java
src/inport/ConversionUtil.java
+112
-2
src/inport/Main.java
src/inport/Main.java
+12
-0
No files found.
constraints/conversion_0.mzn
View file @
963aead7
...
@@ -52,8 +52,8 @@ constraint forall (i in 1..n_operations, j in 1..(n_intervals + 1)) (op_start[i,
...
@@ -52,8 +52,8 @@ constraint forall (i in 1..n_operations, j in 1..(n_intervals + 1)) (op_start[i,
constraint
forall
(
i
in
1
..
n_operations
,
j
in
1
..
n_intervals
)
(
op_fin
[
i
,
j
]
=
(
op_status
[
i
,
j
]
/\
not
op_status
[
i
,
j
+
1
]));
constraint
forall
(
i
in
1
..
n_operations
,
j
in
1
..
n_intervals
)
(
op_fin
[
i
,
j
]
=
(
op_status
[
i
,
j
]
/\
not
op_status
[
i
,
j
+
1
]));
% Непрерывность перемещения и швартовки.
% Непрерывность перемещения и швартовки.
array
[
1
..
n_operations
]
of
var
int
:
operations_duration
;
array
[
1
..
n_operations
]
of
int
:
operations_duration
;
array
[
1
..
n_operations
]
of
var
bool
:
is_continuous_operation
;
array
[
1
..
n_operations
]
of
bool
:
is_continuous_operation
;
constraint
forall
(
i
in
1
..
n_operations
where
is_continuous_operation
[
i
])
(
constraint
forall
(
i
in
1
..
n_operations
where
is_continuous_operation
[
i
])
(
let
{
var
int
:
len
=
operations_duration
[
i
]}
in
let
{
var
int
:
len
=
operations_duration
[
i
]}
in
...
...
constraints/conversion_1.mzn
View file @
963aead7
This diff is collapsed.
Click to expand it.
src/inport/ConversionUtil.java
View file @
963aead7
...
@@ -636,7 +636,7 @@ public class ConversionUtil {
...
@@ -636,7 +636,7 @@ public class ConversionUtil {
}
}
/* Ограничение на необходимость полезной операции между движениями к одному пункту назначения. */
/* Ограничение на необходимость полезной операции между движениями к одному пункту назначения. */
private
void
constraintOnUsefulOperationBetweenMovements
()
throws
IOException
{
private
void
constraintOnUsefulOperationBetweenMovements
_0
()
throws
IOException
{
ArrayList
<
Set
<
Integer
>>
objUsefulOperations
=
new
ArrayList
<>();
ArrayList
<
Set
<
Integer
>>
objUsefulOperations
=
new
ArrayList
<>();
ArrayList
<
Set
<
Integer
>>
movingOpOfObj
=
new
ArrayList
<>();
ArrayList
<
Set
<
Integer
>>
movingOpOfObj
=
new
ArrayList
<>();
...
@@ -684,6 +684,76 @@ public class ConversionUtil {
...
@@ -684,6 +684,76 @@ public class ConversionUtil {
writer
.
write
(
"\n"
);
writer
.
write
(
"\n"
);
}
}
private
void
constraintOnUsefulOperationBetweenMovements_1
()
throws
IOException
{
ArrayList
<
Set
<
Integer
>>
objUsefulOperations
=
new
ArrayList
<>();
BiConsumer
<
MovingObject
,
Integer
>
addUsOp
=
(
MovingObject
obj
,
Integer
op
)
->
objUsefulOperations
.
get
(
mObjToN
.
apply
(
obj
)).
add
(
op
+
1
);
for
(
int
i
=
0
;
i
<
movingObjects
.
size
();
i
++)
{
objUsefulOperations
.
add
(
new
TreeSet
<>());
}
for
(
int
i
=
0
;
i
<
operationTemplates
.
size
();
i
++)
{
OperationTemplate
t
=
operationTemplates
.
get
(
i
);
if
(
t
instanceof
MovingTemplate
)
{
MovingTemplate
op
=
(
MovingTemplate
)
t
;
for
(
MovingObject
obj
:
op
.
getResources
())
{
addUsOp
.
accept
(
obj
,
i
);
}
}
else
if
(
t
instanceof
MooringTemplate
)
{
MooringTemplate
op
=
(
MooringTemplate
)
t
;
for
(
MovingObject
obj
:
op
.
getResources
())
{
addUsOp
.
accept
(
obj
,
i
);
}
if
(!
op
.
isDirect
())
{
// Отшвартовка.
addUsOp
.
accept
(
op
.
getMoorer
(),
i
);
}
}
else
if
(
t
instanceof
LoadingTemplate
)
{
LoadingTemplate
op
=
(
LoadingTemplate
)
t
;
addUsOp
.
accept
(
op
.
getLoader
(),
i
);
}
}
writeArrayOfSetAs2DArray
(
writer
,
"obj_useful_operations"
,
objUsefulOperations
);
writer
.
write
(
"\n"
);
}
private
void
movingObjectLocationDefinition
()
throws
IOException
{
ArrayList
<
Set
<
Integer
>>
movingOpOfObj
=
new
ArrayList
<>();
ArrayList
<
Integer
>
operationsDestination
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
movingObjects
.
size
();
i
++)
{
movingOpOfObj
.
add
(
new
TreeSet
<>());
}
for
(
int
i
=
0
;
i
<
operationTemplates
.
size
();
i
++)
{
OperationTemplate
t
=
operationTemplates
.
get
(
i
);
if
((
t
instanceof
MovingTemplate
)
||
(
t
instanceof
MooringTemplate
))
{
int
id
=
mObjToN
.
apply
(
getExecutor
(
t
));
movingOpOfObj
.
get
(
id
).
add
(
i
+
1
);
}
if
(
t
instanceof
MovingTemplate
)
{
MovingTemplate
op
=
(
MovingTemplate
)
t
;
operationsDestination
.
add
(
getLocNById
.
apply
(
op
.
getDestination
().
getId
(),
false
));
}
else
if
(
t
instanceof
MooringTemplate
)
{
MooringTemplate
op
=
(
MooringTemplate
)
t
;
operationsDestination
.
add
(
getLocNById
.
apply
(
op
.
getStartLocation
().
getId
(),
op
.
isDirect
()));
}
else
{
// TODO аккуратно обработать погрузку.
operationsDestination
.
add
(
getLocNById
.
apply
(
t
.
getStartLocation
().
getId
(),
false
));
}
}
writeArrayOfSetAs2DArray
(
writer
,
"moving_op_of_obj"
,
movingOpOfObj
);
writeArray
(
writer
,
"operations_destination"
,
operationsDestination
,
(
Integer
val
)
->
val
+
1
);
writer
.
write
(
"\n"
);
}
void
portToMiniZinc_0
()
throws
IOException
{
void
portToMiniZinc_0
()
throws
IOException
{
try
{
try
{
writer
=
new
FileWriter
(
fileName
,
false
);
writer
=
new
FileWriter
(
fileName
,
false
);
...
@@ -711,7 +781,42 @@ public class ConversionUtil {
...
@@ -711,7 +781,42 @@ public class ConversionUtil {
cargoFlows
();
cargoFlows
();
cargoOperations
();
cargoOperations
();
constraintOnUsefulOperationBetweenMovements
();
constraintOnUsefulOperationBetweenMovements_0
();
}
finally
{
if
(
writer
!=
null
)
{
writer
.
close
();
}
}
}
void
portToMiniZinc_1
()
throws
IOException
{
try
{
writer
=
new
FileWriter
(
fileName
,
false
);
writer
.
write
(
"n_intervals = "
+
n_intervals
+
";\n"
);
writer
.
write
(
"n_operations = "
+
task
.
getTemplates
().
size
()
+
";\n"
);
writer
.
write
(
"n_locations = "
+
locationNumberById
.
size
()
+
";\n"
);
writer
.
write
(
"n_moving_obj = "
+
movingObjects
.
size
()
+
";\n"
);
writer
.
write
(
"\n"
);
movingObjectLocationDefinition
();
initialLocations
();
weatherWindows
();
operationsContinuity
();
finalLocations
();
presenceOfResourcesInLocation
();
conflictingOperations
();
writer
.
write
(
"n_obj_with_storage = "
+
nObjWithStorage
+
";\n"
);
writer
.
write
(
"n_cargo_types = "
+
cargoes
.
size
()
+
";\n"
);
maxStorageVolume
();
boundaryStorageStates
();
cargoFlows
();
cargoOperations
();
constraintOnUsefulOperationBetweenMovements_1
();
}
finally
{
}
finally
{
if
(
writer
!=
null
)
{
if
(
writer
!=
null
)
{
writer
.
close
();
writer
.
close
();
...
@@ -725,6 +830,11 @@ public class ConversionUtil {
...
@@ -725,6 +830,11 @@ public class ConversionUtil {
taskData
.
portToMiniZinc_0
();
taskData
.
portToMiniZinc_0
();
}
}
static
public
void
portToMiniZinc_1
(
TaskCase
task
,
String
fileName
)
throws
IOException
{
Task
taskData
=
new
Task
(
task
,
fileName
);
taskData
.
portToMiniZinc_1
();
}
static
public
void
resolveMiniZincResults
(
TaskCase
task
,
String
fileName
)
throws
IOException
,
ParserException
{
static
public
void
resolveMiniZincResults
(
TaskCase
task
,
String
fileName
)
throws
IOException
,
ParserException
{
List
<
Operation
>
operations
=
null
;
List
<
Operation
>
operations
=
null
;
Integer
result
=
null
;
Integer
result
=
null
;
...
...
src/inport/Main.java
View file @
963aead7
...
@@ -23,6 +23,18 @@ public class Main {
...
@@ -23,6 +23,18 @@ public class Main {
}
}
break
;
break
;
}
}
case
"to_MiniZinc_1"
:
{
String
input
=
args
[
1
];
String
output
=
args
[
2
];
TaskCase
task
=
new
TaskCase
();
try
{
task
.
deserialize
(
input
);
ConversionUtil
.
portToMiniZinc_1
(
task
,
output
);
}
catch
(
IOException
ex
)
{
System
.
out
.
println
(
ex
.
getMessage
());
}
break
;
}
case
"resolve_result"
:
{
case
"resolve_result"
:
{
String
input
=
args
[
1
];
String
input
=
args
[
1
];
String
fileWIthResult
=
args
[
2
];
String
fileWIthResult
=
args
[
2
];
...
...
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