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
f52cfc4b
Commit
f52cfc4b
authored
May 14, 2019
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Тестирование с разными параметрами, time limit.
parent
4746f729
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
207 additions
and
80 deletions
+207
-80
src/inport/Main.java
src/inport/Main.java
+59
-50
src/inport/Testing.java
src/inport/Testing.java
+148
-30
No files found.
src/inport/Main.java
View file @
f52cfc4b
...
...
@@ -4,12 +4,18 @@ import java.io.*;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.function.BiFunction
;
import
java.util.function.Function
;
import
static
inport
.
Testing
.*;
import
static
inport
.
Testing
.
solveTaskWithPartialCargoOp
;
import
inport.ConversionUtil.*
;
public
class
Main
{
static
final
int
DEFAULT_TIME_LIMIT_S
=
1
;
public
static
void
main
(
String
[]
args
)
{
if
(
args
.
length
==
0
)
{
System
.
out
.
println
(
"To few arguments."
);
...
...
@@ -32,9 +38,9 @@ public class Main {
String
error
;
if
(!
task
.
isTypified
())
{
error
=
solveTask_1
(
task
);
error
=
solveTask_1
(
task
,
DEFAULT_TIME_LIMIT_S
);
}
else
{
error
=
solveTask_2
(
task
);
error
=
solveTask_2
(
task
,
DEFAULT_TIME_LIMIT_S
);
}
long
finish
=
System
.
currentTimeMillis
();
...
...
@@ -89,69 +95,72 @@ public class Main {
break
;
}
case
"debug"
:
{
String
fileName
=
"experiment/in.ipp"
;
String
solverResults
=
"temp_data/solver_results.txt"
;
String
output
=
"experiment/debug_info.txt"
;
TaskCase
task
=
new
TaskCase
();
try
{
task
.
deserialize
(
fileName
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
break
;
}
String
error
=
solveTask_2
(
task
);
if
(!
error
.
isEmpty
())
{
System
.
out
.
println
(
"Error : "
+
error
);
break
;
}
else
{
task
.
serialize
(
fileName
);
}
debugInfo
(
task
,
solverResults
,
output
);
debug
(
Testing:
:
solveTask_2
,
DEFAULT_TIME_LIMIT_S
);
break
;
}
case
"debug 2"
:
{
String
fileName
=
"experiment/in.ipp"
;
String
solverResults
=
"temp_data/solver_results.txt"
;
String
output
=
"experiment/debug_info.txt"
;
TaskCase
task
=
new
TaskCase
();
try
{
task
.
deserialize
(
fileName
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
break
;
}
String
error
=
solveTaskWithPartialCargoOp
(
task
);
if
(!
error
.
isEmpty
())
{
System
.
out
.
println
(
"Error : "
+
error
);
break
;
}
else
{
task
.
serialize
(
fileName
);
}
debugInfo
(
task
,
solverResults
,
output
);
debug
(
Testing:
:
solveTaskWithPartialCargoOp
,
DEFAULT_TIME_LIMIT_S
);
break
;
}
case
"testing"
:
test_2
();
test_2
(
DEFAULT_TIME_LIMIT_S
);
break
;
case
"testing_with_partial_op"
:
testWithPartialOp
();
testWithPartialOp
(
DEFAULT_TIME_LIMIT_S
);
break
;
case
"testing_exp"
:
test_2_exp
();
case
"different_parameters"
:
try
{
testingWithDiffParameters
(
"tests/with_typing/Case2.tipp"
,
1
,
30
,
16
,
35
,
1.1
,
30
);
// testingWithDiffParameters(
// "tests/with_typing/TaskT.tipp",
// 10, 10,
// 32, 32,
// 1.1, 10);
}
catch
(
IOException
ex
)
{
System
.
out
.
println
(
ex
.
getMessage
());
}
break
;
default
:
System
.
out
.
println
(
"Unknown type \""
+
type
+
"\""
);
}
}
private
static
void
debug
(
BiFunction
<
TaskCase
,
Integer
,
String
>
solver
,
int
timeLimitS
)
{
String
fileName
=
"experiment/in.ipp"
;
String
solverResults
=
"temp_data/solver_results.txt"
;
String
output
=
"experiment/debug_info.txt"
;
TaskCase
task
=
new
TaskCase
();
try
{
task
.
deserialize
(
fileName
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
return
;
}
long
start
=
System
.
currentTimeMillis
();
String
error
=
solver
.
apply
(
task
,
timeLimitS
);
long
finish
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
" "
+
(
finish
-
start
)
/
1000.0
+
" s"
);
if
(!
error
.
isEmpty
())
{
System
.
out
.
println
(
"Error : "
+
error
);
return
;
}
else
{
task
.
serialize
(
fileName
);
}
debugInfo
(
task
,
solverResults
,
output
);
}
private
static
void
debugInfo
(
TaskCase
task
,
String
solverResults
,
String
output
)
{
try
(
FileInputStream
fstream
=
new
FileInputStream
(
solverResults
))
{
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
fstream
));
...
...
src/inport/Testing.java
View file @
f52cfc4b
This diff is collapsed.
Click to expand it.
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