Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2019-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
adc2019
adc2019-system
Commits
ade1d6c0
Commit
ade1d6c0
authored
Aug 20, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to load existing solutions on starting
parent
b3919864
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
data.py
utils/data.py
+25
-5
No files found.
utils/data.py
View file @
ade1d6c0
import
datetime
import
glob
import
json
import
math
import
os
...
...
@@ -26,6 +27,14 @@ class Problem(object):
self
.
block_groups
=
list
()
self
.
_load_problem
(
problem_path
)
if
not
self
.
solution_path
is
None
:
solution_files
=
glob
.
glob
(
f
'{self.solution_path}/{self.name}/*.json'
)
for
v
in
solution_files
:
solution
=
Solution
(
solution_file
=
v
)
solution_id
=
solution
.
get_id
()
print
(
f
'I: Put a solution: {solution_id}'
)
self
.
solutions
[
solution_id
]
=
solution
@
property
def
size_str
(
self
):
...
...
@@ -336,7 +345,11 @@ class Problem(object):
class
Solution
(
object
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
=
None
,
solution_file
=
None
):
if
not
solution_file
is
None
:
with
open
(
solution_file
,
'r'
)
as
fp
:
data
=
json
.
load
(
fp
)
self
.
problem
=
data
[
'problem'
]
self
.
request_id
=
data
[
'request_id'
]
...
...
@@ -344,15 +357,21 @@ class Solution(object):
self
.
elapsed_time
=
data
[
'elapsed_time'
]
self
.
solution
=
data
[
'solution'
]
self
.
status
=
data
[
'status'
]
self
.
size
=
(
None
,
None
)
self
.
map
=
None
self
.
block
=
dict
()
self
.
timestamp
=
time
.
time
()
self
.
_id
=
str
(
uuid
.
uuid4
())
if
solution_file
is
None
:
self
.
timestamp
=
time
.
time
()
self
.
_id
=
str
(
uuid
.
uuid4
())
else
:
self
.
timestamp
=
data
[
'timestamp'
]
self
.
_id
=
data
[
'id'
]
self
.
_parse_solution
()
def
_parse_solution
(
self
):
if
self
.
status
!=
'done'
:
...
...
@@ -429,7 +448,8 @@ class Solution(object):
'worker'
:
self
.
worker
,
'elapsed_time'
:
self
.
elapsed_time
,
'problem'
:
self
.
problem
,
'solution'
:
self
.
solution
'solution'
:
self
.
solution
,
'status'
:
self
.
status
}
def
get_d3json
(
self
):
...
...
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