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
f75c0cc0
Commit
f75c0cc0
authored
Jun 20, 2019
by
Vladislav Kiselev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Теперь фиксированные операции задаются отдельно от решения.
parent
1297c475
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
59 deletions
+82
-59
src/inport/ConversionUtil.java
src/inport/ConversionUtil.java
+3
-12
src/inport/Operation.java
src/inport/Operation.java
+47
-2
src/inport/TaskCase.java
src/inport/TaskCase.java
+27
-45
tests/with_typing/Bunkers.tipp
tests/with_typing/Bunkers.tipp
+2
-0
tests/with_typing/FixedOperations.tipp
tests/with_typing/FixedOperations.tipp
+3
-0
No files found.
src/inport/ConversionUtil.java
View file @
f75c0cc0
...
...
@@ -1321,7 +1321,7 @@ public class ConversionUtil {
isFixed
.
get
(
i
).
add
(
false
);
}
}
for
(
Operation
op
:
task
.
get
Solution
())
{
for
(
Operation
op
:
task
.
get
FixedOperations
())
{
if
(
op
.
getFixation
())
{
int
operation
=
opNoByOpIdAndExecutorNo
.
get
(
new
Pair
<>(
op
.
getTemplate
().
getId
(),
op
.
getExecutor
().
getId
()));
...
...
@@ -1378,7 +1378,7 @@ public class ConversionUtil {
opNoByOpData
.
put
(
new
OperationData
(
op
.
getId
(),
getExecutor
(
op
).
getId
(),
bunkerId
),
i
);
}
for
(
Operation
op
:
task
.
get
Solution
())
{
for
(
Operation
op
:
task
.
get
FixedOperations
())
{
if
(
op
.
getFixation
())
{
OptionalInt
bunkerId
=
op
.
getBunker
().
map
(
b
->
OptionalInt
.
of
(
b
.
getId
())).
orElse
(
OptionalInt
.
empty
());
...
...
@@ -1580,15 +1580,6 @@ public class ConversionUtil {
}
}
// System.out.print("#######\n");
// for (int i = 0; i < sectionNById.size(); i++) {
// for (Integer val : positionsOfConnectedSections.get(i)) {
// System.out.print(val + " ");
// }
// System.out.print("\n");
// }
// System.out.print("---\n");
ArrayList
<
Integer
>
operationsMainStorNoInSecondary
=
new
ArrayList
<>();
ArrayList
<
Integer
>
operationsSecondaryStorNoInMain
=
new
ArrayList
<>();
...
...
@@ -1901,7 +1892,7 @@ public class ConversionUtil {
isFixed
=
task
.
getIsFixedArray
();
Set
<
String
>
oldSolution
=
new
TreeSet
<>();
for
(
Operation
op
:
taskCase
.
get
Solution
())
{
for
(
Operation
op
:
taskCase
.
get
FixedOperations
())
{
if
(
op
.
getFixation
())
{
oldSolution
.
add
(
op
.
toString
());
}
...
...
src/inport/Operation.java
View file @
f75c0cc0
...
...
@@ -4,8 +4,7 @@
*/
package
inport
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.*
;
/**
*
...
...
@@ -143,4 +142,50 @@ public class Operation {
sb
.
append
(
")"
);
return
sb
.
toString
();
}
public
Operation
(
String
str
,
Map
<
Integer
,
MovingObject
>
m_vessel
,
Map
<
Integer
,
Bunker
>
m_bunker
,
Map
<
Integer
,
LoadingEquipment
>
m_equipment
,
Map
<
Integer
,
OperationTemplate
>
m_template
)
{
String
lStr
=
str
.
substring
(
0
,
str
.
indexOf
(
'('
)).
trim
();
String
rStr
=
str
.
substring
(
str
.
indexOf
(
'('
)
+
1
,
str
.
indexOf
(
')'
)).
trim
();
{
String
[]
items
=
lStr
.
split
(
";"
);
setStart
(
Double
.
parseDouble
(
items
[
2
].
trim
()));
setDuration
(
Double
.
parseDouble
(
items
[
3
].
trim
()));
setTemplate
(
m_template
.
get
(
Integer
.
parseInt
(
items
[
0
].
trim
())));
setFixation
(
items
[
1
].
trim
().
equals
(
"F"
));
}
{
String
[]
items
=
rStr
.
substring
(
rStr
.
indexOf
(
'['
)
+
1
,
rStr
.
indexOf
(
']'
)).
split
(
","
);
ArrayList
<
MovingObject
>
resources
=
new
ArrayList
<>();
for
(
String
item
:
items
)
{
if
(
item
.
trim
().
isEmpty
())
{
continue
;
}
resources
.
add
(
m_equipment
.
get
(
Integer
.
valueOf
(
item
.
trim
())));
}
setResources
(
resources
);
}
{
String
[]
items
=
rStr
.
substring
(
0
,
rStr
.
indexOf
(
'['
)).
split
(
" "
);
MovingObject
ex
=
m_vessel
.
get
(
Integer
.
valueOf
(
items
[
0
].
trim
()));
if
(
ex
==
null
)
{
ex
=
m_bunker
.
get
(
Integer
.
valueOf
(
items
[
0
].
trim
()));
}
setExecutor
(
ex
);
if
(
items
.
length
>
1
)
{
setBunker
(
Optional
.
of
(
m_bunker
.
get
(
Integer
.
valueOf
(
items
[
1
].
trim
()))));
}
}
String
intensity
=
rStr
.
substring
(
rStr
.
indexOf
(
']'
)
+
1
).
trim
();
if
(!
intensity
.
isEmpty
())
{
setIntensity
(
Optional
.
of
(
Integer
.
valueOf
(
intensity
)));
}
}
}
src/inport/TaskCase.java
View file @
f75c0cc0
...
...
@@ -60,16 +60,26 @@ public class TaskCase {
// Горизонт планирования
private
double
planningInterval
;
// Зафиксированные операции.
private
List
<
Operation
>
fixedOperations
;
// Тип критерия оптимизации
private
int
criterionType
;
// План - критерий
private
double
solution_result
;
// План - решение
private
List
<
Operation
>
solution
;
public
List
<
Operation
>
getFixedOperations
()
{
return
fixedOperations
;
}
public
void
setFixedOperations
(
List
<
Operation
>
fixedOperations
)
{
this
.
fixedOperations
=
fixedOperations
;
}
public
Map
<
Integer
,
String
>
getBunkerTypes
()
{
return
bunkerTypes
;
}
...
...
@@ -408,7 +418,9 @@ public class TaskCase {
vesselEndState
=
new
ArrayList
<>();
storageEndState
=
new
ArrayList
<>();
fixedOperations
=
new
ArrayList
<>();
solution
=
new
ArrayList
<>();
}
...
...
@@ -448,6 +460,7 @@ public class TaskCase {
Final_Vessel_State
(
"Final Vessel State"
),
Final_Storage_State
(
"Final Storage State"
),
Task_Properties
(
"Task Properties"
),
Fixed_Operations
(
"Fixed Operations"
),
Solution
(
"Solution"
);
private
final
String
text
;
...
...
@@ -469,6 +482,7 @@ public class TaskCase {
cargoes
.
clear
();
berths
.
clear
();
storages
.
clear
();
bunkers
.
clear
();
tows
.
clear
();
equipments
.
clear
();
ships
.
clear
();
templates
.
clear
();
cargoFlows
.
clear
();
vesselInitialState
.
clear
();
storageInitialState
.
clear
();
vesselEndState
.
clear
();
storageEndState
.
clear
();
bunkerTypes
.
clear
();
fixedOperations
.
clear
();
solution
.
clear
();
// Open the file
...
...
@@ -688,51 +702,14 @@ public class TaskCase {
criterionType
=
Integer
.
parseInt
(
rs
[
1
].
trim
());
}
break
;
case
Fixed_Operations:
fixedOperations
.
add
(
new
Operation
(
strLine
,
m_vessel
,
m_bunker
,
m_equipment
,
m_template
));
break
;
case
Solution:
// Чтение операций.
if
(
numInside
==
1
)
{
solution_result
=
Double
.
parseDouble
(
strLine
.
trim
());
}
else
{
String
lStr
=
strLine
.
substring
(
0
,
strLine
.
indexOf
(
'('
)).
trim
();
String
rStr
=
strLine
.
substring
(
strLine
.
indexOf
(
'('
)
+
1
,
strLine
.
indexOf
(
')'
)).
trim
();
Operation
op
=
new
Operation
();
{
String
[]
items
=
lStr
.
split
(
";"
);
op
.
setStart
(
Double
.
parseDouble
(
items
[
2
].
trim
()));
op
.
setDuration
(
Double
.
parseDouble
(
items
[
3
].
trim
()));
op
.
setTemplate
(
m_template
.
get
(
Integer
.
parseInt
(
items
[
0
].
trim
())));
op
.
setFixation
(
items
[
1
].
trim
().
equals
(
"F"
));
}
{
String
[]
items
=
rStr
.
substring
(
rStr
.
indexOf
(
'['
)
+
1
,
rStr
.
indexOf
(
']'
)).
split
(
","
);
ArrayList
<
MovingObject
>
resources
=
new
ArrayList
<>();
for
(
String
item
:
items
)
{
if
(
item
.
trim
().
isEmpty
())
{
continue
;
}
resources
.
add
(
m_equipment
.
get
(
Integer
.
valueOf
(
item
.
trim
())));
}
op
.
setResources
(
resources
);
}
{
String
[]
items
=
rStr
.
substring
(
0
,
rStr
.
indexOf
(
'['
)).
split
(
" "
);
MovingObject
ex
=
m_vessel
.
get
(
Integer
.
valueOf
(
items
[
0
].
trim
()));
if
(
ex
==
null
)
{
ex
=
m_bunker
.
get
(
Integer
.
valueOf
(
items
[
0
].
trim
()));
}
op
.
setExecutor
(
ex
);
if
(
items
.
length
>
1
)
{
op
.
setBunker
(
Optional
.
of
(
m_bunker
.
get
(
Integer
.
valueOf
(
items
[
1
].
trim
()))));
}
}
String
intensity
=
rStr
.
substring
(
rStr
.
indexOf
(
']'
)
+
1
).
trim
();
if
(!
intensity
.
isEmpty
())
{
op
.
setIntensity
(
Optional
.
of
(
Integer
.
valueOf
(
intensity
)));
}
solution
.
add
(
op
);
solution
.
add
(
new
Operation
(
strLine
,
m_vessel
,
m_bunker
,
m_equipment
,
m_template
));
}
break
;
default
:
...
...
@@ -822,6 +799,11 @@ public class TaskCase {
writer
.
write
(
"\n"
);
writer
.
write
(
"\nTask Properties"
+
"\n"
);
writer
.
write
(
planningInterval
+
"; "
+
criterionType
+
"\n"
);
writer
.
write
(
"\n"
+
Tag
.
Fixed_Operations
.
text
+
"\n"
);
for
(
Operation
op
:
fixedOperations
)
{
writer
.
write
(
op
.
toString
()
+
"\n"
);
}
writer
.
write
(
"\n"
);
writer
.
write
(
"\nSolution"
+
"\n"
);
writer
.
write
(
solution_result
+
"\n"
);
...
...
tests/with_typing/Bunkers.tipp
View file @
f75c0cc0
...
...
@@ -76,6 +76,8 @@ Final Storage State
Task Properties
20.0; 0
Fixed Operations
20; F; 1.0; 2.0 (101 202 [] 2)
Solution
8.0
...
...
tests/with_typing/FixedOperations.tipp
View file @
f75c0cc0
...
...
@@ -62,6 +62,9 @@ Final Storage State
Task Properties
30.0; 0
Fixed Operations
21; F; 0.0; 3.0 (5 [])
19; F; 6.0; 3.0 (5 [] 10)
Solution
18.0
...
...
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