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
0c7bd9c1
Commit
0c7bd9c1
authored
Jul 08, 2019
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Main улучшен
parent
ad5581f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
39 deletions
+36
-39
src/inport/Main.java
src/inport/Main.java
+36
-39
No files found.
src/inport/Main.java
View file @
0c7bd9c1
...
@@ -16,16 +16,17 @@ public class Main {
...
@@ -16,16 +16,17 @@ public class Main {
private
static
final
int
DEFAULT_TIME_LIMIT_S
=
3600
;
private
static
final
int
DEFAULT_TIME_LIMIT_S
=
3600
;
private
enum
ConversionType
{
private
enum
ConversionType
{
Undefined
(
""
,
""
),
Undefined
(
""
,
(
TaskCase
t
,
Integer
i
)
->
""
),
WithoutSplitting
(
"Without splitting"
,
"conversion_2.mzn"
),
WithoutSplitting
(
"Without splitting"
,
Testing:
:
solveTask_2
),
WithSplitting
(
"With splitting"
,
"conversion_2_with_partial_cargo_operations.mzn"
),
WithSplitting
(
"With splitting"
,
Testing:
:
solveTaskWithPartialCargoOp
),
Greedy_v2
(
"Greedy v2"
,
"conversion_2_greedy_v2.mzn"
);
Greedy
(
"Greedy"
,
Testing:
:
solveTaskWithGreedyConstraints
),
Greedy_v2
(
"Greedy v2"
,
Testing:
:
solveTaskWithGreedyConstraintsV2
);
private
final
String
text
;
private
final
String
text
;
private
final
String
constraintName
;
private
final
BiFunction
<
TaskCase
,
Integer
,
String
>
solver
;
ConversionType
(
String
text
,
String
constraintName
)
{
ConversionType
(
String
text
,
BiFunction
<
TaskCase
,
Integer
,
String
>
solver
)
{
this
.
text
=
text
;
this
.
text
=
text
;
this
.
constraintName
=
constraintName
;
this
.
solver
=
solver
;
}
}
public
static
ConversionType
fromString
(
String
text
)
{
public
static
ConversionType
fromString
(
String
text
)
{
for
(
ConversionType
t
:
ConversionType
.
values
())
{
for
(
ConversionType
t
:
ConversionType
.
values
())
{
...
@@ -37,6 +38,18 @@ public class Main {
...
@@ -37,6 +38,18 @@ public class Main {
}
}
}
}
private
static
String
undefinedTypeErrorMess
(
String
undefType
)
{
StringBuilder
s
=
new
StringBuilder
(
"Undefined conversion type - \""
+
undefType
+
"\".\n"
);
ArrayList
<
String
>
values
=
new
ArrayList
<>();
for
(
ConversionType
conversionType
:
ConversionType
.
values
())
{
if
(!
conversionType
.
equals
(
ConversionType
.
Undefined
))
{
values
.
add
(
"\""
+
conversionType
.
text
+
"\""
);
}
}
s
.
append
(
"Conversion type can be one of "
).
append
(
String
.
join
(
", "
,
values
)).
append
(
"."
);
return
s
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
if
(
args
.
length
==
0
)
{
if
(
args
.
length
==
0
)
{
System
.
out
.
println
(
"To few arguments."
);
System
.
out
.
println
(
"To few arguments."
);
...
@@ -63,25 +76,11 @@ public class Main {
...
@@ -63,25 +76,11 @@ public class Main {
}
else
{
}
else
{
ConversionType
t
=
(
args
.
length
==
2
)
?
ConversionType
.
WithoutSplitting
ConversionType
t
=
(
args
.
length
==
2
)
?
ConversionType
.
WithoutSplitting
:
ConversionType
.
fromString
(
args
[
2
]);
:
ConversionType
.
fromString
(
args
[
2
]);
if
(
t
.
equals
(
ConversionType
.
Undefined
))
{
if
(
t
.
equals
(
ConversionType
.
Undefined
))
{
System
.
out
.
println
(
"Undefined conversion type - \""
+
args
[
2
]
+
"\"."
);
System
.
out
.
println
(
undefinedTypeErrorMess
(
args
[
2
]));
ArrayList
<
String
>
values
=
new
ArrayList
<>();
for
(
ConversionType
conversionType
:
ConversionType
.
values
())
{
if
(!
conversionType
.
equals
(
ConversionType
.
Undefined
))
{
values
.
add
(
"\""
+
conversionType
.
text
+
"\""
);
}
}
System
.
out
.
print
(
"Conversion type can be one of "
+
String
.
join
(
", "
,
values
)
+
"."
);
return
;
return
;
}
}
error
=
solveTask
(
error
=
t
.
solver
.
apply
(
task
,
DEFAULT_TIME_LIMIT_S
);
task
,
t
.
constraintName
,
Task:
:
portToMiniZinc_2
,
MZnResultsResolver:
:
resolveMiniZincResults
,
DEFAULT_TIME_LIMIT_S
);
}
}
long
finish
=
System
.
currentTimeMillis
();
long
finish
=
System
.
currentTimeMillis
();
...
@@ -136,19 +135,13 @@ public class Main {
...
@@ -136,19 +135,13 @@ public class Main {
break
;
break
;
}
}
case
"debug"
:
{
case
"debug"
:
{
debug
(
Testing:
:
solveTask_2
,
DEFAULT_TIME_LIMIT_S
);
ConversionType
t
=
(
args
.
length
==
2
)
?
ConversionType
.
WithoutSplitting
break
;
:
ConversionType
.
fromString
(
args
[
2
]);
}
if
(
t
.
equals
(
ConversionType
.
Undefined
))
{
case
"debug 2"
:
{
System
.
out
.
println
(
undefinedTypeErrorMess
(
args
[
2
]));
debug
(
Testing:
:
solveTaskWithPartialCargoOp
,
DEFAULT_TIME_LIMIT_S
);
return
;
break
;
}
}
debug
(
t
.
solver
,
DEFAULT_TIME_LIMIT_S
);
case
"debug greedy"
:
{
debug
(
Testing:
:
solveTaskWithGreedyConstraints
,
DEFAULT_TIME_LIMIT_S
);
break
;
}
case
"debug greedy v2"
:
{
debug
(
Testing:
:
solveTaskWithGreedyConstraintsV2
,
DEFAULT_TIME_LIMIT_S
);
break
;
break
;
}
}
case
"debug read-write"
:
{
case
"debug read-write"
:
{
...
@@ -156,14 +149,18 @@ public class Main {
...
@@ -156,14 +149,18 @@ public class Main {
break
;
break
;
}
}
case
"testing"
:
case
"testing"
:
ConversionType
t
=
(
args
.
length
==
2
)
?
ConversionType
.
WithoutSplitting
:
ConversionType
.
fromString
(
args
[
2
]);
if
(
t
.
equals
(
ConversionType
.
Undefined
))
{
System
.
out
.
println
(
undefinedTypeErrorMess
(
args
[
2
]));
return
;
}
testGroup
(
"with_typing"
,
t
.
solver
,
DEFAULT_TIME_LIMIT_S
);
test_2
(
DEFAULT_TIME_LIMIT_S
);
test_2
(
DEFAULT_TIME_LIMIT_S
);
break
;
break
;
case
"test_experiment"
:
case
"test_experiment"
:
testGroup
(
"experiments"
,
Testing:
:
solveTask_2
,
DEFAULT_TIME_LIMIT_S
);
testGroup
(
"experiments"
,
Testing:
:
solveTask_2
,
DEFAULT_TIME_LIMIT_S
);
break
;
break
;
case
"testing_with_partial_op"
:
testWithPartialOp
(
DEFAULT_TIME_LIMIT_S
);
break
;
case
"different_parameters"
:
case
"different_parameters"
:
try
{
try
{
testingWithDiffParameters
(
testingWithDiffParameters
(
...
...
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