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
Show 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 {
@Override
public
String
toString
()
{
return
id
+
";"
+
name
;
return
id
+
";
"
+
name
;
}
public
Berth
(
String
s
)
{
...
...
src/inport/Cargo.java
View file @
2e554245
...
...
@@ -79,7 +79,7 @@ public class Cargo {
@Override
public
String
toString
()
{
return
id
+
";
"
+
name
+
";
"
+
cost
;
return
id
+
";
"
+
name
+
";
"
+
cost
;
}
public
Cargo
(
String
s
)
{
...
...
src/inport/CargoFlow.java
View file @
2e554245
...
...
@@ -117,7 +117,7 @@ public class CargoFlow {
res
+=
s
+
":"
+
flow
.
get
(
s
);
first
=
false
;
}
return
storage
.
getId
()
+
";["
+
res
+
"]"
;
return
storage
.
getId
()
+
";
["
+
res
+
"]"
;
}
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 {
}
}
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
)
{
ArrayList
<
Operation
>
operations
=
null
;
Integer
result
=
null
;
...
...
@@ -1330,8 +1324,6 @@ public class ConversionUtil {
}
}
}
operations
.
sort
(
new
OperationsComparator
());
task
.
setSolution
(
operations
);
task
.
setSolution_result
(
result
);
}
catch
(
IOException
e
)
{
...
...
src/inport/LoadingEquipment.java
View file @
2e554245
...
...
@@ -32,8 +32,8 @@ public class LoadingEquipment extends MovingObject{
public
LoadingEquipment
(
String
s
)
{
super
(
s
);
String
[]
tokens
=
s
.
split
(
";"
);
if
(
tokens
.
length
>=
4
)
{
setType
(
OptionalInt
.
of
(
Integer
.
parseInt
(
tokens
[
3
].
trim
())));
if
(
tokens
.
length
>=
3
)
{
setType
(
OptionalInt
.
of
(
Integer
.
parseInt
(
tokens
[
2
].
trim
())));
}
}
...
...
src/inport/LoadingTemplate.java
View file @
2e554245
...
...
@@ -125,7 +125,7 @@ public class LoadingTemplate extends OperationTemplate {
}
for
(
Integer
t
:
getResourcesTypes
())
{
if
(!
first
)
res
+=
","
+
t
;
res
+=
",
"
+
t
;
else
res
+=
t
;
first
=
false
;
...
...
src/inport/Main.java
View file @
2e554245
...
...
@@ -5,9 +5,7 @@ import java.util.ArrayList;
import
java.util.Map
;
import
java.util.TreeMap
;
import
static
inport
.
Testing
.
solveTask_1
;
import
static
inport
.
Testing
.
solveTask_2
;
import
static
inport
.
Testing
.
test_1
;
import
static
inport
.
Testing
.*;
import
inport.ConversionUtil.*
;
public
class
Main
{
...
...
@@ -117,7 +115,7 @@ public class Main {
break
;
}
case
"testing"
:
test_
1
();
test_
2
();
break
;
default
:
System
.
out
.
println
(
"Unknown type \""
+
type
+
"\""
);
...
...
src/inport/MovingObjectState.java
View file @
2e554245
...
...
@@ -64,7 +64,7 @@ public class MovingObjectState {
@Override
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 {
@Override
public
String
toString
()
{
return
id
+
";
"
+
name
+
";"
+
cargo
.
getId
()
+
";
"
+
volume
;
return
id
+
";
"
+
name
+
"; "
+
cargo
.
getId
()
+
";
"
+
volume
;
}
public
Storage
(
String
s
,
Map
<
Integer
,
Cargo
>
cargoes
)
{
...
...
src/inport/StorageState.java
View file @
2e554245
...
...
@@ -76,9 +76,9 @@ public class StorageState {
@Override
public
String
toString
()
{
if
(
storage
instanceof
Storage
)
return
cargo
.
getId
()
+
";
"
+
((
Storage
)
storage
).
getId
()
+
";
"
+
cargoState
;
return
cargo
.
getId
()
+
";
"
+
((
Storage
)
storage
).
getId
()
+
";
"
+
cargoState
;
if
(
storage
instanceof
TransportShip
)
return
cargo
.
getId
()
+
";
"
+
((
TransportShip
)
storage
).
getId
()
+
";
"
+
cargoState
;
return
cargo
.
getId
()
+
";
"
+
((
TransportShip
)
storage
).
getId
()
+
";
"
+
cargoState
;
return
""
;
}
...
...
src/inport/TaskCase.java
View file @
2e554245
...
...
@@ -663,6 +663,12 @@ public class TaskCase {
}
}
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
)
{
try
(
FileWriter
writer
=
new
FileWriter
(
fileName
,
false
))
...
...
@@ -670,67 +676,69 @@ public class TaskCase {
// запись всего
writer
.
write
(
Tag
.
Typified
.
text
+
"\n"
+
(
isTypified
()?
"1"
:
"0"
)
+
"\n"
);
writer
.
write
(
"Cargoes"
+
"\n"
);
writer
.
write
(
"
\n
Cargoes"
+
"\n"
);
for
(
Cargo
c
:
cargoes
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Berths"
+
"\n"
);
writer
.
write
(
"
\n
Berths"
+
"\n"
);
for
(
Berth
c
:
berths
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Storages"
+
"\n"
);
writer
.
write
(
"
\n
Storages"
+
"\n"
);
for
(
Storage
c
:
storages
)
{
writer
.
write
(
c
.
toString
()
+
"\n"
);
}
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
())
{
writer
.
write
(
e
.
getKey
()
+
"; "
+
e
.
getValue
()
+
"\n"
);
}
}
writer
.
write
(
"Bunkers"
+
"\n"
);
writer
.
write
(
"
\n
Bunkers"
+
"\n"
);
for
(
Bunker
c
:
bunkers
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Tows"
+
"\n"
);
writer
.
write
(
"
\n
Tows"
+
"\n"
);
for
(
Tow
c
:
tows
)
{
writer
.
write
(
c
.
toString
()
+
"\n"
);
}
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
())
{
writer
.
write
(
e
.
getKey
()
+
"; "
+
e
.
getValue
()
+
"\n"
);
}
}
writer
.
write
(
"Loading Equipments"
+
"\n"
);
writer
.
write
(
"
\n
Loading Equipments"
+
"\n"
);
for
(
LoadingEquipment
c
:
equipments
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Transport Ships"
+
"\n"
);
writer
.
write
(
"
\n
Transport Ships"
+
"\n"
);
for
(
TransportShip
c
:
ships
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"Templates"
+
"\n"
);
writer
.
write
(
"\nTemplates"
+
"\n"
);
for
(
OperationTemplate
c
:
templates
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"Cargo Flows"
+
"\n"
);
writer
.
write
(
"
\n
Cargo Flows"
+
"\n"
);
for
(
CargoFlow
c
:
cargoFlows
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Initial Vessel State"
+
"\n"
);
writer
.
write
(
"
\n
Initial Vessel State"
+
"\n"
);
for
(
MovingObjectState
c
:
vesselInitialState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Initial Storage State"
+
"\n"
);
writer
.
write
(
"
\n
Initial Storage State"
+
"\n"
);
for
(
StorageState
c
:
storageInitialState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Final Vessel State"
+
"\n"
);
writer
.
write
(
"
\n
Final Vessel State"
+
"\n"
);
for
(
MovingObjectState
c
:
vesselEndState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"Final Storage State"
+
"\n"
);
writer
.
write
(
"
\n
Final Storage State"
+
"\n"
);
for
(
StorageState
c
:
storageEndState
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"Task Properties"
+
"\n"
);
writer
.
write
(
planningInterval
+
";"
+
criterionType
+
"\n"
);
writer
.
write
(
"
\n
Task Properties"
+
"\n"
);
writer
.
write
(
planningInterval
+
";
"
+
criterionType
+
"\n"
);
writer
.
write
(
"\n"
);
writer
.
write
(
"Solution"
+
"\n"
);
writer
.
write
(
"
\n
Solution"
+
"\n"
);
writer
.
write
(
solution_result
+
"\n"
);
solution
.
sort
(
new
OperationsComparator
());
for
(
Operation
c
:
solution
)
writer
.
write
(
c
.
toString
()+
"\n"
);
writer
.
flush
();
...
...
src/inport/Testing.java
View file @
2e554245
...
...
@@ -3,6 +3,7 @@ package inport;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.function.BiConsumer
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
public
class
Testing
{
...
...
@@ -71,12 +72,12 @@ public class Testing {
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
String
output
=
br
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
BufferedReader
br2
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getErrorStream
()));
String
errors
=
br
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
//
BufferedReader br2 = new BufferedReader(new InputStreamReader(process.getErrorStream()));
//
String errors = br.lines().collect(Collectors.joining("\n"));
System
.
out
.
println
(
"output : "
+
output
);
System
.
out
.
println
(
"errors : "
+
errors
);
//
System.out.println("output : " + output);
//
System.out.println("errors : " + errors);
if
(
output
.
trim
().
equals
(
"=====UNSATISFIABLE====="
))
{
task
.
setSolution
(
new
ArrayList
<>());
...
...
@@ -92,7 +93,7 @@ public class Testing {
return
""
;
}
p
ublic
static
String
testCase
(
String
file
)
{
p
rivate
static
String
testCase
(
String
file
,
Function
<
TaskCase
,
String
>
solver
)
{
TaskCase
task
=
new
TaskCase
();
try
{
task
.
deserialize
(
file
);
...
...
@@ -100,7 +101,7 @@ public class Testing {
return
"Error : "
+
e
.
getMessage
();
}
double
expected_result
=
task
.
getSolution_result
();
String
error
=
solve
Task_1
(
task
);
String
error
=
solve
r
.
apply
(
task
);
double
result
=
task
.
getSolution_result
();
if
(!
error
.
isEmpty
())
{
return
"Error : "
+
error
;
...
...
@@ -111,8 +112,8 @@ public class Testing {
return
"OK"
;
}
public
static
void
test
_1
(
)
{
File
testDir
=
new
File
(
"tests/
without_typing
/"
);
public
static
void
test
Group
(
String
group
,
Function
<
TaskCase
,
String
>
solver
)
{
File
testDir
=
new
File
(
"tests/
"
+
group
+
"
/"
);
System
.
out
.
println
(
testDir
.
toString
()
+
" :"
);
int
nPassedTests
=
0
;
...
...
@@ -122,7 +123,7 @@ public class Testing {
long
start
=
System
.
currentTimeMillis
();
String
res
=
testCase
(
testDir
.
toString
()
+
"/"
+
file
.
getName
());
String
res
=
testCase
(
testDir
.
toString
()
+
"/"
+
file
.
getName
()
,
solver
);
long
finish
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
" "
+
res
+
", "
+
(
finish
-
start
)
+
" ms"
);
...
...
@@ -132,4 +133,12 @@ public class Testing {
}
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