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
92827ce4
Commit
92827ce4
authored
Aug 15, 2019
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Устранена ошибка с оптимизацией 3.
parent
9e4d4fde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
11 deletions
+29
-11
src/inport/ConversionUtils/Task.java
src/inport/ConversionUtils/Task.java
+28
-10
src/inport/Testing.java
src/inport/Testing.java
+1
-1
No files found.
src/inport/ConversionUtils/Task.java
View file @
92827ce4
...
@@ -1242,7 +1242,7 @@ public class Task {
...
@@ -1242,7 +1242,7 @@ public class Task {
writeArray
(
writer
,
"bunker_start_loc"
,
bunkerStartLoc
,
(
Integer
val
)
->
val
+
1
,
Optional
.
of
(-
1
));
writeArray
(
writer
,
"bunker_start_loc"
,
bunkerStartLoc
,
(
Integer
val
)
->
val
+
1
,
Optional
.
of
(-
1
));
}
}
void
dataForOptimization3
()
throws
IOException
{
void
dataForOptimization3
(
boolean
isInseparable
)
throws
IOException
{
ArrayList
<
ArrayList
<
Integer
>>
min_positive_cargo_val
=
arrayOfIntegerArrays
(
sectionNById
.
size
());
ArrayList
<
ArrayList
<
Integer
>>
min_positive_cargo_val
=
arrayOfIntegerArrays
(
sectionNById
.
size
());
ArrayList
<
ArrayList
<
Integer
>>
max_negative_cargo_val
=
arrayOfIntegerArrays
(
sectionNById
.
size
());
ArrayList
<
ArrayList
<
Integer
>>
max_negative_cargo_val
=
arrayOfIntegerArrays
(
sectionNById
.
size
());
ArrayList
<
ArrayList
<
Boolean
>>
can_obj_leave_loc_only_alone
=
new
ArrayList
<>();
ArrayList
<
ArrayList
<
Boolean
>>
can_obj_leave_loc_only_alone
=
new
ArrayList
<>();
...
@@ -1274,10 +1274,19 @@ public class Task {
...
@@ -1274,10 +1274,19 @@ public class Task {
sections
.
add
(
new
Pair
<>(
sectionIdToN
(
op
.
getStorage
(),
op
.
getCargo
()),
-
val
));
sections
.
add
(
new
Pair
<>(
sectionIdToN
(
op
.
getStorage
(),
op
.
getCargo
()),
-
val
));
}
}
for
(
Pair
<
Integer
,
Integer
>
p
:
sections
)
{
for
(
Pair
<
Integer
,
Integer
>
p
:
sections
)
{
if
(
p
.
getValue
()
>
0
)
{
Integer
value
=
p
.
getValue
();
min_positive_cargo_val
.
get
(
p
.
getKey
()).
set
(
loc
,
Math
.
min
(
p
.
getValue
(),
min_positive_cargo_val
.
get
(
p
.
getKey
()).
get
(
loc
)));
if
(!
isInseparable
)
{
if
(
value
<
0
)
{
value
=
-
1
;
}
if
(
value
>
0
)
{
value
=
1
;
}
}
if
(
value
>
0
)
{
min_positive_cargo_val
.
get
(
p
.
getKey
()).
set
(
loc
,
Math
.
min
(
value
,
min_positive_cargo_val
.
get
(
p
.
getKey
()).
get
(
loc
)));
}
else
{
}
else
{
max_negative_cargo_val
.
get
(
p
.
getKey
()).
set
(
loc
,
Math
.
max
(
p
.
getValue
()
,
max_negative_cargo_val
.
get
(
p
.
getKey
()).
get
(
loc
)));
max_negative_cargo_val
.
get
(
p
.
getKey
()).
set
(
loc
,
Math
.
max
(
value
,
max_negative_cargo_val
.
get
(
p
.
getKey
()).
get
(
loc
)));
}
}
}
}
}
else
if
(
t
instanceof
MovingTemplate
)
{
}
else
if
(
t
instanceof
MovingTemplate
)
{
...
@@ -1290,16 +1299,22 @@ public class Task {
...
@@ -1290,16 +1299,22 @@ public class Task {
}
}
}
}
write2DArrayOfInt
(
writer
,
"min_positive_cargo_val"
,
min_positive_cargo_val
,
false
);
write2DArrayOfInt
(
writer
,
"min_positive_cargo_val"
,
min_positive_cargo_val
,
false
);
write2DArrayOfInt
(
writer
,
"max_negative_cargo_val"
,
max_negative_cargo_val
,
false
);
write2DArrayOfInt
(
writer
,
"max_negative_cargo_val"
,
max_negative_cargo_val
,
false
);
locWrite2DArray
(
writer
,
"can_obj_leave_loc_only_alone"
,
can_obj_leave_loc_only_alone
,
Objects:
:
toString
);
locWrite2DArray
(
writer
,
"can_obj_leave_loc_only_alone"
,
can_obj_leave_loc_only_alone
,
Objects:
:
toString
);
writer
.
write
(
"\n"
);
writer
.
write
(
"\n"
);
}
}
void
portToMiniZinc_2_sep
()
{
portToMiniZinc_2
(
false
);
}
void
portToMiniZinc_2_inSep
()
{
portToMiniZinc_2
(
true
);
}
/* С типизацией. */
/* С типизацией. */
void
portToMiniZinc_2
(
)
{
private
void
portToMiniZinc_2
(
boolean
isInseparable
)
{
if
(!
task
.
isTypified
())
{
if
(!
task
.
isTypified
())
{
throw
new
ParserException
(
"Attempt to convert untyped task as typified."
);
throw
new
ParserException
(
"Attempt to convert untyped task as typified."
);
}
}
...
@@ -1336,7 +1351,7 @@ public class Task {
...
@@ -1336,7 +1351,7 @@ public class Task {
boundaryStorageStates
();
boundaryStorageStates
();
cargoFlows
();
cargoFlows
();
cargoOperations
();
cargoOperations
();
dataForOptimization3
();
dataForOptimization3
(
isInseparable
);
fixedOperations
();
fixedOperations
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -1512,7 +1527,7 @@ public class Task {
...
@@ -1512,7 +1527,7 @@ public class Task {
throw
new
ParserException
(
"Attempt to convert untyped task as typified."
);
throw
new
ParserException
(
"Attempt to convert untyped task as typified."
);
}
}
try
{
try
{
portToMiniZinc_2
();
portToMiniZinc_2
(
false
);
dataForGreediness
();
dataForGreediness
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
UncheckedIOException
(
e
);
throw
new
UncheckedIOException
(
e
);
...
@@ -1539,7 +1554,10 @@ public class Task {
...
@@ -1539,7 +1554,10 @@ public class Task {
startConversion
(
task
,
fileName
,
Task:
:
portToMiniZinc_1
);
startConversion
(
task
,
fileName
,
Task:
:
portToMiniZinc_1
);
}
}
static
public
void
portToMiniZinc_2
(
TaskCase
task
,
String
fileName
)
{
static
public
void
portToMiniZinc_2
(
TaskCase
task
,
String
fileName
)
{
startConversion
(
task
,
fileName
,
Task:
:
portToMiniZinc_2
);
startConversion
(
task
,
fileName
,
Task:
:
portToMiniZinc_2_inSep
);
}
static
public
void
portToMiniZinc_2_separable
(
TaskCase
task
,
String
fileName
)
{
startConversion
(
task
,
fileName
,
Task:
:
portToMiniZinc_2_sep
);
}
}
static
public
void
portToMiniZincGreedy
(
TaskCase
task
,
String
fileName
)
{
static
public
void
portToMiniZincGreedy
(
TaskCase
task
,
String
fileName
)
{
startConversion
(
task
,
fileName
,
Task:
:
portToMiniZinc_2_greedy
);
startConversion
(
task
,
fileName
,
Task:
:
portToMiniZinc_2_greedy
);
...
...
src/inport/Testing.java
View file @
92827ce4
...
@@ -20,7 +20,7 @@ public class Testing {
...
@@ -20,7 +20,7 @@ public class Testing {
public
static
Solver
getTaskWithPartialCargoOp_Solver
()
{
public
static
Solver
getTaskWithPartialCargoOp_Solver
()
{
return
new
Solver
(
"conversion_2_with_partial_cargo_operations.mzn"
,
return
new
Solver
(
"conversion_2_with_partial_cargo_operations.mzn"
,
Task:
:
portToMiniZinc_2
,
Task:
:
portToMiniZinc_2
_separable
,
MZnResultsResolver:
:
resolveMiniZincResults
);
MZnResultsResolver:
:
resolveMiniZincResults
);
}
}
...
...
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