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
62bd0d72
Commit
62bd0d72
authored
Dec 03, 2018
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
few bugs fixed
parent
57cda042
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
constraints/conversion_1.mzn
constraints/conversion_1.mzn
+3
-1
src/inport/ConversionUtil.java
src/inport/ConversionUtil.java
+25
-11
No files found.
constraints/conversion_1.mzn
View file @
62bd0d72
...
@@ -41,7 +41,7 @@ array [1..n_moving_obj, 0..(n_intervals + 1)] of var bool : is_m_obj_in_movement
...
@@ -41,7 +41,7 @@ array [1..n_moving_obj, 0..(n_intervals + 1)] of var bool : is_m_obj_in_movement
if
(
current_moving_operation
[
obj
,
t
-
1
]
=
0
)
then
if
(
current_moving_operation
[
obj
,
t
-
1
]
=
0
)
then
is_m_obj_in_movement_before_start
[
obj
,
t
]
=
false
is_m_obj_in_movement_before_start
[
obj
,
t
]
=
false
else
else
is_m_obj_in_movement_before_start
[
obj
,
t
]
=
(
current_moving_operation
[
obj
,
t
-
1
]
!
=
current_moving_operation
[
obj
,
t
])
is_m_obj_in_movement_before_start
[
obj
,
t
]
=
(
current_moving_operation
[
obj
,
t
-
1
]
=
=
current_moving_operation
[
obj
,
t
])
endif
endif
);
);
...
@@ -285,6 +285,8 @@ output [show(sum(is_not_terminated)), "\n",
...
@@ -285,6 +285,8 @@ output [show(sum(is_not_terminated)), "\n",
"op_start = "
,
show
(
op_start
),
"\n\n"
,
"op_start = "
,
show
(
op_start
),
"\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"
,
"storage_used_volume = "
,
show
(
storage_used_volume
),
"\n\n"
,
"is_m_obj_in_movement_before_start = "
,
show
(
is_m_obj_in_movement_before_start
),
"\n\n"
,
"current_moving_operation = "
,
show
(
current_moving_operation
),
"\n\n"
% "prev_m_obj_loc = ", show(prev_m_obj_loc), "\n\n",
% "prev_m_obj_loc = ", show(prev_m_obj_loc), "\n\n",
% "next_m_obj_loc = ", show(next_m_obj_loc), "\n\n",
% "next_m_obj_loc = ", show(next_m_obj_loc), "\n\n",
% "is_interval_useful = ", show(is_interval_useful), "\n\n"
% "is_interval_useful = ", show(is_interval_useful), "\n\n"
...
...
src/inport/ConversionUtil.java
View file @
62bd0d72
...
@@ -201,8 +201,8 @@ public class ConversionUtil {
...
@@ -201,8 +201,8 @@ public class ConversionUtil {
return
null
;
return
null
;
}
}
static
private
List
<
Object
>
getResources
(
OperationTemplate
t
)
{
static
private
List
<
Moving
Object
>
getResources
(
OperationTemplate
t
)
{
List
<
Object
>
res
=
new
ArrayList
<>();
List
<
Moving
Object
>
res
=
new
ArrayList
<>();
if
(
t
instanceof
LoadingTemplate
)
{
if
(
t
instanceof
LoadingTemplate
)
{
res
.
addAll
(((
LoadingTemplate
)
t
).
getResources
());
res
.
addAll
(((
LoadingTemplate
)
t
).
getResources
());
}
}
...
@@ -218,11 +218,11 @@ public class ConversionUtil {
...
@@ -218,11 +218,11 @@ public class ConversionUtil {
static
private
boolean
isCompatible
(
OperationTemplate
t1
,
OperationTemplate
t2
)
{
static
private
boolean
isCompatible
(
OperationTemplate
t1
,
OperationTemplate
t2
)
{
MovingObject
exec1
=
getExecutor
(
t1
);
MovingObject
exec1
=
getExecutor
(
t1
);
Berth
place1
=
t1
.
getStartLocation
();
Berth
place1
=
t1
.
getStartLocation
();
List
<
Object
>
resources1
=
getResources
(
t1
);
List
<
Moving
Object
>
resources1
=
getResources
(
t1
);
MovingObject
exec2
=
getExecutor
(
t2
);
MovingObject
exec2
=
getExecutor
(
t2
);
Berth
place2
=
t2
.
getStartLocation
();
Berth
place2
=
t2
.
getStartLocation
();
List
<
Object
>
resources2
=
getResources
(
t2
);
List
<
Moving
Object
>
resources2
=
getResources
(
t2
);
// Пересекаемость ресурсов
// Пересекаемость ресурсов
for
(
Object
res2
:
resources2
)
for
(
Object
res2
:
resources2
)
if
(
resources1
.
contains
(
res2
))
if
(
resources1
.
contains
(
res2
))
...
@@ -643,6 +643,8 @@ public class ConversionUtil {
...
@@ -643,6 +643,8 @@ public class ConversionUtil {
BiConsumer
<
MovingObject
,
Integer
>
addUsOp
=
(
MovingObject
obj
,
Integer
op
)
->
BiConsumer
<
MovingObject
,
Integer
>
addUsOp
=
(
MovingObject
obj
,
Integer
op
)
->
objUsefulOperations
.
get
(
mObjToN
.
apply
(
obj
)).
add
(
op
+
1
);
objUsefulOperations
.
get
(
mObjToN
.
apply
(
obj
)).
add
(
op
+
1
);
BiConsumer
<
MovingObject
,
Integer
>
addMovingOp
=
(
MovingObject
obj
,
Integer
op
)
->
movingOpOfObj
.
get
(
mObjToN
.
apply
(
obj
)).
add
(
op
+
1
);
for
(
int
i
=
0
;
i
<
movingObjects
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
movingObjects
.
size
();
i
++)
{
movingOpOfObj
.
add
(
new
TreeSet
<>());
movingOpOfObj
.
add
(
new
TreeSet
<>());
...
@@ -654,20 +656,20 @@ public class ConversionUtil {
...
@@ -654,20 +656,20 @@ public class ConversionUtil {
if
(
t
instanceof
MovingTemplate
)
{
if
(
t
instanceof
MovingTemplate
)
{
MovingTemplate
op
=
(
MovingTemplate
)
t
;
MovingTemplate
op
=
(
MovingTemplate
)
t
;
int
id
=
mObjToN
.
apply
(
op
.
getMover
());
addMovingOp
.
accept
(
op
.
getMover
(),
i
);
movingOpOfObj
.
get
(
id
).
add
(
i
+
1
);
for
(
MovingObject
obj
:
op
.
getResources
())
{
for
(
MovingObject
obj
:
op
.
getResources
())
{
addUsOp
.
accept
(
obj
,
i
);
addUsOp
.
accept
(
obj
,
i
);
addMovingOp
.
accept
(
obj
,
i
);
}
}
}
else
if
(
t
instanceof
MooringTemplate
)
{
}
else
if
(
t
instanceof
MooringTemplate
)
{
MooringTemplate
op
=
(
MooringTemplate
)
t
;
MooringTemplate
op
=
(
MooringTemplate
)
t
;
int
id
=
mObjToN
.
apply
(
op
.
getMoorer
());
addMovingOp
.
accept
(
op
.
getMoorer
(),
i
);
movingOpOfObj
.
get
(
id
).
add
(
i
+
1
);
for
(
MovingObject
obj
:
op
.
getResources
())
{
for
(
MovingObject
obj
:
op
.
getResources
())
{
addUsOp
.
accept
(
obj
,
i
);
addUsOp
.
accept
(
obj
,
i
);
addMovingOp
.
accept
(
obj
,
i
);
}
}
if
(!
op
.
isDirect
())
{
// Отшвартовка.
if
(!
op
.
isDirect
())
{
// Отшвартовка.
...
@@ -730,12 +732,17 @@ public class ConversionUtil {
...
@@ -730,12 +732,17 @@ public class ConversionUtil {
movingOpOfObj
.
add
(
new
TreeSet
<>());
movingOpOfObj
.
add
(
new
TreeSet
<>());
}
}
BiConsumer
<
MovingObject
,
Integer
>
addMovingOp
=
(
MovingObject
obj
,
Integer
op
)
->
movingOpOfObj
.
get
(
mObjToN
.
apply
(
obj
)).
add
(
op
+
1
);
for
(
int
i
=
0
;
i
<
operationTemplates
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
operationTemplates
.
size
();
i
++)
{
OperationTemplate
t
=
operationTemplates
.
get
(
i
);
OperationTemplate
t
=
operationTemplates
.
get
(
i
);
if
((
t
instanceof
MovingTemplate
)
||
(
t
instanceof
MooringTemplate
))
{
if
((
t
instanceof
MovingTemplate
)
||
(
t
instanceof
MooringTemplate
))
{
int
id
=
mObjToN
.
apply
(
getExecutor
(
t
));
addMovingOp
.
accept
(
getExecutor
(
t
),
i
);
movingOpOfObj
.
get
(
id
).
add
(
i
+
1
);
for
(
MovingObject
obj
:
getResources
(
t
))
{
addMovingOp
.
accept
(
obj
,
i
);
}
}
}
if
(
t
instanceof
MovingTemplate
)
{
if
(
t
instanceof
MovingTemplate
)
{
MovingTemplate
op
=
(
MovingTemplate
)
t
;
MovingTemplate
op
=
(
MovingTemplate
)
t
;
...
@@ -835,8 +842,14 @@ public class ConversionUtil {
...
@@ -835,8 +842,14 @@ public class ConversionUtil {
taskData
.
portToMiniZinc_1
();
taskData
.
portToMiniZinc_1
();
}
}
private
static
class
OperationsComparator
implements
Comparator
<
Operation
>
{
public
int
compare
(
Operation
op1
,
Operation
op2
)
{
return
Double
.
compare
(
op1
.
getStart
(),
op2
.
getStart
());
}
}
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
;
Array
List
<
Operation
>
operations
=
null
;
Integer
result
=
null
;
Integer
result
=
null
;
try
(
FileInputStream
fstream
=
new
FileInputStream
(
fileName
))
{
try
(
FileInputStream
fstream
=
new
FileInputStream
(
fileName
))
{
...
@@ -906,6 +919,7 @@ public class ConversionUtil {
...
@@ -906,6 +919,7 @@ public class ConversionUtil {
if
(
result
==
null
)
{
if
(
result
==
null
)
{
throw
new
ParserException
(
"No result in input"
);
throw
new
ParserException
(
"No result in input"
);
}
}
operations
.
sort
(
new
OperationsComparator
());
task
.
setSolution
(
operations
);
task
.
setSolution
(
operations
);
task
.
setSolution_result
(
result
);
task
.
setSolution_result
(
result
);
}
}
...
...
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