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
2e554245
Commit
2e554245
authored
Mar 28, 2019
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавлено тестирование типизированных тестов, исправлено оформление.
parent
c8542a5d
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
59 additions
and
52 deletions
+59
-52
src/inport/Berth.java
src/inport/Berth.java
+1
-1
src/inport/Cargo.java
src/inport/Cargo.java
+1
-1
src/inport/CargoFlow.java
src/inport/CargoFlow.java
+1
-1
src/inport/ConversionUtil.java
src/inport/ConversionUtil.java
+0
-8
src/inport/LoadingEquipment.java
src/inport/LoadingEquipment.java
+2
-2
src/inport/LoadingTemplate.java
src/inport/LoadingTemplate.java
+1
-1
src/inport/Main.java
src/inport/Main.java
+2
-4
src/inport/MovingObjectState.java
src/inport/MovingObjectState.java
+1
-1
src/inport/Storage.java
src/inport/Storage.java
+1
-1
src/inport/StorageState.java
src/inport/StorageState.java
+2
-2
src/inport/TaskCase.java
src/inport/TaskCase.java
+29
-21
src/inport/Testing.java
src/inport/Testing.java
+18
-9
No files found.
src/inport/Berth.java
View file @
2e554245
...
@@ -69,7 +69,7 @@ public class Berth {
...
@@ -69,7 +69,7 @@ public class Berth {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
id
+
";"
+
name
;
return
id
+
";
"
+
name
;
}
}
public
Berth
(
String
s
)
{
public
Berth
(
String
s
)
{
...
...
src/inport/Cargo.java
View file @
2e554245
...
@@ -79,7 +79,7 @@ public class Cargo {
...
@@ -79,7 +79,7 @@ public class Cargo {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
id
+
";
"
+
name
+
";
"
+
cost
;
return
id
+
";
"
+
name
+
";
"
+
cost
;
}
}
public
Cargo
(
String
s
)
{
public
Cargo
(
String
s
)
{
...
...
src/inport/CargoFlow.java
View file @
2e554245
...
@@ -117,7 +117,7 @@ public class CargoFlow {
...
@@ -117,7 +117,7 @@ public class CargoFlow {
res
+=
s
+
":"
+
flow
.
get
(
s
);
res
+=
s
+
":"
+
flow
.
get
(
s
);
first
=
false
;
first
=
false
;
}
}
return
storage
.
getId
()
+
";["
+
res
+
"]"
;
return
storage
.
getId
()
+
";
["
+
res
+
"]"
;
}
}
public
CargoFlow
(
String
s
,
Map
<
Integer
,
Storage
>
mp
,
Map
<
Integer
,
Cargo
>
cp
)
{
public
CargoFlow
(
String
s
,
Map
<
Integer
,
Storage
>
mp
,
Map
<
Integer
,
Cargo
>
cp
)
{
...
...
src/inport/ConversionUtil.java
View file @
2e554245
...
@@ -1175,12 +1175,6 @@ public class ConversionUtil {
...
@@ -1175,12 +1175,6 @@ public class ConversionUtil {
}
}
}
}
private
static
class
OperationsComparator
implements
Comparator
<
Operation
>
{
public
int
compare
(
Operation
op1
,
Operation
op2
)
{
return
Double
.
compare
(
op1
.
getStart
(),
op2
.
getStart
());
}
}
public
static
void
resolveMiniZincResults
(
TaskCase
task
,
String
fileName
)
{
public
static
void
resolveMiniZincResults
(
TaskCase
task
,
String
fileName
)
{
ArrayList
<
Operation
>
operations
=
null
;
ArrayList
<
Operation
>
operations
=
null
;
Integer
result
=
null
;
Integer
result
=
null
;
...
@@ -1330,8 +1324,6 @@ public class ConversionUtil {
...
@@ -1330,8 +1324,6 @@ public class ConversionUtil {
}
}
}
}
}
}
operations
.
sort
(
new
OperationsComparator
());
task
.
setSolution
(
operations
);
task
.
setSolution
(
operations
);
task
.
setSolution_result
(
result
);
task
.
setSolution_result
(
result
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
src/inport/LoadingEquipment.java
View file @
2e554245
...
@@ -32,8 +32,8 @@ public class LoadingEquipment extends MovingObject{
...
@@ -32,8 +32,8 @@ public class LoadingEquipment extends MovingObject{
public
LoadingEquipment
(
String
s
)
{
public
LoadingEquipment
(
String
s
)
{
super
(
s
);
super
(
s
);
String
[]
tokens
=
s
.
split
(
";"
);
String
[]
tokens
=
s
.
split
(
";"
);
if
(
tokens
.
length
>=
4
)
{
if
(
tokens
.
length
>=
3
)
{
setType
(
OptionalInt
.
of
(
Integer
.
parseInt
(
tokens
[
3
].
trim
())));
setType
(
OptionalInt
.
of
(
Integer
.
parseInt
(
tokens
[
2
].
trim
())));
}
}
}
}
...
...
src/inport/LoadingTemplate.java
View file @
2e554245
...
@@ -125,7 +125,7 @@ public class LoadingTemplate extends OperationTemplate {
...
@@ -125,7 +125,7 @@ public class LoadingTemplate extends OperationTemplate {
}
}
for
(
Integer
t
:
getResourcesTypes
())
{
for
(
Integer
t
:
getResourcesTypes
())
{
if
(!
first
)
if
(!
first
)
res
+=
","
+
t
;
res
+=
",
"
+
t
;
else
else
res
+=
t
;
res
+=
t
;
first
=
false
;
first
=
false
;
...
...
src/inport/Main.java
View file @
2e554245
...
@@ -5,9 +5,7 @@ import java.util.ArrayList;
...
@@ -5,9 +5,7 @@ import java.util.ArrayList;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
static
inport
.
Testing
.
solveTask_1
;
import
static
inport
.
Testing
.*;
import
static
inport
.
Testing
.
solveTask_2
;
import
static
inport
.
Testing
.
test_1
;
import
inport.ConversionUtil.*
;
import
inport.ConversionUtil.*
;
public
class
Main
{
public
class
Main
{
...
@@ -117,7 +115,7 @@ public class Main {
...
@@ -117,7 +115,7 @@ public class Main {
break
;
break
;
}
}
case
"testing"
:
case
"testing"
:
test_
1
();
test_
2
();
break
;
break
;
default
:
default
:
System
.
out
.
println
(
"Unknown type \""
+
type
+
"\""
);
System
.
out
.
println
(
"Unknown type \""
+
type
+
"\""
);
...
...
src/inport/MovingObjectState.java
View file @
2e554245
...
@@ -64,7 +64,7 @@ public class MovingObjectState {
...
@@ -64,7 +64,7 @@ public class MovingObjectState {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
getVessel
().
getId
()
+
";"
+
getLocation
().
getId
();
return
getVessel
().
getId
()
+
";
"
+
getLocation
().
getId
();
}
}
...
...
src/inport/Storage.java
View file @
2e554245
...
@@ -101,7 +101,7 @@ public class Storage {
...
@@ -101,7 +101,7 @@ public class Storage {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
id
+
";
"
+
name
+
";"
+
cargo
.
getId
()
+
";
"
+
volume
;
return
id
+
";
"
+
name
+
"; "
+
cargo
.
getId
()
+
";
"
+
volume
;
}
}
public
Storage
(
String
s
,
Map
<
Integer
,
Cargo
>
cargoes
)
{
public
Storage
(
String
s
,
Map
<
Integer
,
Cargo
>
cargoes
)
{
...
...
src/inport/StorageState.java
View file @
2e554245
...
@@ -76,9 +76,9 @@ public class StorageState {
...
@@ -76,9 +76,9 @@ public class StorageState {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
if
(
storage
instanceof
Storage
)
if
(
storage
instanceof
Storage
)
return
cargo
.
getId
()
+
";
"
+
((
Storage
)
storage
).
getId
()
+
";
"
+
cargoState
;
return
cargo
.
getId
()
+
";
"
+
((
Storage
)
storage
).
getId
()
+
";
"
+
cargoState
;
if
(
storage
instanceof
TransportShip
)
if
(
storage
instanceof
TransportShip
)
return
cargo
.
getId
()
+
";
"
+
((
TransportShip
)
storage
).
getId
()
+
";
"
+
cargoState
;
return
cargo
.
getId
()
+
";
"
+
((
TransportShip
)
storage
).
getId
()
+
";
"
+
cargoState
;
return
""
;
return
""
;
}
}
...
...
src/inport/TaskCase.java
View file @
2e554245
...
@@ -662,7 +662,13 @@ public class TaskCase {
...
@@ -662,7 +662,13 @@ public class TaskCase {
Logger
.
getLogger
(
TaskCase
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
TaskCase
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
private
static
class
OperationsComparator
implements
Comparator
<
Operation
>
{
public
int
compare
(
Operation
op1
,
Operation
op2
)
{
return
Double
.
compare
(
op1
.
getStart
(),
op2
.
getStart
());
}
}
public
void
serialize
(
String
fileName
)
public
void
serialize
(
String
fileName
)
{
{
try
(
FileWriter
writer
=
new
FileWriter
(
fileName
,
false
))
try
(
FileWriter
writer
=
new
FileWriter
(
fileName
,
false
))
...
@@ -670,67 +676,69 @@ public class TaskCase {
...
@@ -670,67 +676,69 @@ public class TaskCase {
// запись всего
// запись всего
writer
.
write
(
Tag
.
Typified
.
text
+
"\n"
+
(
isTypified
()?
"1"
:
"0"
)
+
"\n"
);
writer
.
write
(
Tag
.
Typified
.
text
+
"\n"
+
(
isTypified
()?
"1"
:
"0"
)
+
"\n"
);
writer
.
write
(
"Cargoes"
+
"\n"
);
writer
.
write
(
"
\n
Cargoes"
+
"\n"
);
for
(
Cargo
c
:
cargoes
)
for
(
Cargo
c
:
cargoes
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Berths"
+
"\n"
);
writer
.
write
(
"
\n
Berths"
+
"\n"
);
for
(
Berth
c
:
berths
)
for
(
Berth
c
:
berths
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Storages"
+
"\n"
);
writer
.
write
(
"
\n
Storages"
+
"\n"
);
for
(
Storage
c
:
storages
)
{
for
(
Storage
c
:
storages
)
{
writer
.
write
(
c
.
toString
()
+
"\n"
);
writer
.
write
(
c
.
toString
()
+
"\n"
);
}
}
if
(
isTypified
())
{
if
(
isTypified
())
{
writer
.
write
(
Tag
.
Vessel_Types
.
text
+
"\n"
);
writer
.
write
(
"\n"
+
Tag
.
Vessel_Types
.
text
+
"\n"
);
for
(
Map
.
Entry
<
Integer
,
String
>
e
:
vesselTypes
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
String
>
e
:
vesselTypes
.
entrySet
())
{
writer
.
write
(
e
.
getKey
()
+
"; "
+
e
.
getValue
()
+
"\n"
);
writer
.
write
(
e
.
getKey
()
+
"; "
+
e
.
getValue
()
+
"\n"
);
}
}
}
}
writer
.
write
(
"Bunkers"
+
"\n"
);
writer
.
write
(
"
\n
Bunkers"
+
"\n"
);
for
(
Bunker
c
:
bunkers
)
for
(
Bunker
c
:
bunkers
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Tows"
+
"\n"
);
writer
.
write
(
"
\n
Tows"
+
"\n"
);
for
(
Tow
c
:
tows
)
{
for
(
Tow
c
:
tows
)
{
writer
.
write
(
c
.
toString
()
+
"\n"
);
writer
.
write
(
c
.
toString
()
+
"\n"
);
}
}
if
(
isTypified
())
{
if
(
isTypified
())
{
writer
.
write
(
Tag
.
Loading_Equipment_Types
.
text
+
"\n"
);
writer
.
write
(
"\n"
+
Tag
.
Loading_Equipment_Types
.
text
+
"\n"
);
for
(
Map
.
Entry
<
Integer
,
String
>
e
:
equipmentTypes
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
String
>
e
:
equipmentTypes
.
entrySet
())
{
writer
.
write
(
e
.
getKey
()
+
"; "
+
e
.
getValue
()
+
"\n"
);
writer
.
write
(
e
.
getKey
()
+
"; "
+
e
.
getValue
()
+
"\n"
);
}
}
}
}
writer
.
write
(
"Loading Equipments"
+
"\n"
);
writer
.
write
(
"
\n
Loading Equipments"
+
"\n"
);
for
(
LoadingEquipment
c
:
equipments
)
for
(
LoadingEquipment
c
:
equipments
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Transport Ships"
+
"\n"
);
writer
.
write
(
"
\n
Transport Ships"
+
"\n"
);
for
(
TransportShip
c
:
ships
)
for
(
TransportShip
c
:
ships
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"\nTemplates"
+
"\n"
);
writer
.
write
(
"Templates"
+
"\n"
);
for
(
OperationTemplate
c
:
templates
)
for
(
OperationTemplate
c
:
templates
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"Cargo Flows"
+
"\n"
);
writer
.
write
(
"
\n
Cargo Flows"
+
"\n"
);
for
(
CargoFlow
c
:
cargoFlows
)
for
(
CargoFlow
c
:
cargoFlows
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Initial Vessel State"
+
"\n"
);
writer
.
write
(
"
\n
Initial Vessel State"
+
"\n"
);
for
(
MovingObjectState
c
:
vesselInitialState
)
for
(
MovingObjectState
c
:
vesselInitialState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Initial Storage State"
+
"\n"
);
writer
.
write
(
"
\n
Initial Storage State"
+
"\n"
);
for
(
StorageState
c
:
storageInitialState
)
for
(
StorageState
c
:
storageInitialState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Final Vessel State"
+
"\n"
);
writer
.
write
(
"
\n
Final Vessel State"
+
"\n"
);
for
(
MovingObjectState
c
:
vesselEndState
)
for
(
MovingObjectState
c
:
vesselEndState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Final Storage State"
+
"\n"
);
writer
.
write
(
"
\n
Final Storage State"
+
"\n"
);
for
(
StorageState
c
:
storageEndState
)
for
(
StorageState
c
:
storageEndState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"Task Properties"
+
"\n"
);
writer
.
write
(
"
\n
Task Properties"
+
"\n"
);
writer
.
write
(
planningInterval
+
";"
+
criterionType
+
"\n"
);
writer
.
write
(
planningInterval
+
";
"
+
criterionType
+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"Solution"
+
"\n"
);
writer
.
write
(
"
\n
Solution"
+
"\n"
);
writer
.
write
(
solution_result
+
"\n"
);
writer
.
write
(
solution_result
+
"\n"
);
solution
.
sort
(
new
OperationsComparator
());
for
(
Operation
c
:
solution
)
for
(
Operation
c
:
solution
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
flush
();
writer
.
flush
();
...
...
src/inport/Testing.java
View file @
2e554245
...
@@ -3,6 +3,7 @@ package inport;
...
@@ -3,6 +3,7 @@ package inport;
import
java.io.*
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.function.BiConsumer
;
import
java.util.function.BiConsumer
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
public
class
Testing
{
public
class
Testing
{
...
@@ -71,12 +72,12 @@ public class Testing {
...
@@ -71,12 +72,12 @@ public class Testing {
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
String
output
=
br
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
String
output
=
br
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
BufferedReader
br2
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getErrorStream
()));
//
BufferedReader br2 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String
errors
=
br
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
//
String errors = br.lines().collect(Collectors.joining("\n"));
System
.
out
.
println
(
"output : "
+
output
);
//
System.out.println("output : " + output);
System
.
out
.
println
(
"errors : "
+
errors
);
//
System.out.println("errors : " + errors);
if
(
output
.
trim
().
equals
(
"=====UNSATISFIABLE====="
))
{
if
(
output
.
trim
().
equals
(
"=====UNSATISFIABLE====="
))
{
task
.
setSolution
(
new
ArrayList
<>());
task
.
setSolution
(
new
ArrayList
<>());
...
@@ -92,7 +93,7 @@ public class Testing {
...
@@ -92,7 +93,7 @@ public class Testing {
return
""
;
return
""
;
}
}
p
ublic
static
String
testCase
(
String
file
)
{
p
rivate
static
String
testCase
(
String
file
,
Function
<
TaskCase
,
String
>
solver
)
{
TaskCase
task
=
new
TaskCase
();
TaskCase
task
=
new
TaskCase
();
try
{
try
{
task
.
deserialize
(
file
);
task
.
deserialize
(
file
);
...
@@ -100,7 +101,7 @@ public class Testing {
...
@@ -100,7 +101,7 @@ public class Testing {
return
"Error : "
+
e
.
getMessage
();
return
"Error : "
+
e
.
getMessage
();
}
}
double
expected_result
=
task
.
getSolution_result
();
double
expected_result
=
task
.
getSolution_result
();
String
error
=
solve
Task_1
(
task
);
String
error
=
solve
r
.
apply
(
task
);
double
result
=
task
.
getSolution_result
();
double
result
=
task
.
getSolution_result
();
if
(!
error
.
isEmpty
())
{
if
(!
error
.
isEmpty
())
{
return
"Error : "
+
error
;
return
"Error : "
+
error
;
...
@@ -111,8 +112,8 @@ public class Testing {
...
@@ -111,8 +112,8 @@ public class Testing {
return
"OK"
;
return
"OK"
;
}
}
public
static
void
test
_1
(
)
{
public
static
void
test
Group
(
String
group
,
Function
<
TaskCase
,
String
>
solver
)
{
File
testDir
=
new
File
(
"tests/
without_typing
/"
);
File
testDir
=
new
File
(
"tests/
"
+
group
+
"
/"
);
System
.
out
.
println
(
testDir
.
toString
()
+
" :"
);
System
.
out
.
println
(
testDir
.
toString
()
+
" :"
);
int
nPassedTests
=
0
;
int
nPassedTests
=
0
;
...
@@ -122,7 +123,7 @@ public class Testing {
...
@@ -122,7 +123,7 @@ public class Testing {
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
String
res
=
testCase
(
testDir
.
toString
()
+
"/"
+
file
.
getName
());
String
res
=
testCase
(
testDir
.
toString
()
+
"/"
+
file
.
getName
()
,
solver
);
long
finish
=
System
.
currentTimeMillis
();
long
finish
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
" "
+
res
+
", "
+
(
finish
-
start
)
+
" ms"
);
System
.
out
.
println
(
" "
+
res
+
", "
+
(
finish
-
start
)
+
" ms"
);
...
@@ -132,4 +133,12 @@ public class Testing {
...
@@ -132,4 +133,12 @@ public class Testing {
}
}
System
.
out
.
println
(
"Passed tests : "
+
nPassedTests
+
"/"
+
testDir
.
listFiles
().
length
);
System
.
out
.
println
(
"Passed tests : "
+
nPassedTests
+
"/"
+
testDir
.
listFiles
().
length
);
}
}
public
static
void
test_1
()
{
testGroup
(
"without_typing"
,
Testing:
:
solveTask_1
);
}
public
static
void
test_2
()
{
testGroup
(
"with_typing"
,
Testing:
:
solveTask_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