Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
geopat
geopat
Commits
c38dfe08
Commit
c38dfe08
authored
Jun 28, 2019
by
Dumoulin Nicolas
Browse files
Building dataframe from geoseries instead of list and dtype fixed
parent
467a8e7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
scenariosAleatoires/MCMC.py
View file @
c38dfe08
...
...
@@ -99,6 +99,7 @@ class MCMC:
:param scenarios: (ScenariosStack) list of the scenarios used as base for sampling the new scenarios.
'''
# Loop of sampling and scoring
start_time
=
time
.
time
()
data
=
{
'scenarios_patches'
:[],
'scenarios_cult'
:[],
'previous_indexes'
:[]}
for
index
,
scenario
in
tqdm
(
scenarios
.
sample
(
nb_particles
,
self
.
rng
).
iterrows
(),
total
=
nb_particles
,
disable
=
disable_progress
):
scenario
=
scenarios
.
reallocate
(
index
)
...
...
@@ -106,12 +107,11 @@ class MCMC:
scenarios
.
setFullReallocated
(
index
,
True
)
else
:
data
[
'scenarios_patches'
].
append
(
scenario
)
data
[
'scenarios_cult'
].
append
(
scenario
[
'cultgeopat'
]
.
to_list
()
)
data
[
'scenarios_cult'
].
append
(
scenario
[
'cultgeopat'
])
data
[
'previous_indexes'
].
append
(
index
)
start_time
=
time
.
time
()
scenarios
.
reconstitute
(
iter_nb
,
**
data
)
elapsed_time
=
time
.
time
()
-
start_time
print
(
'
scenarios evaluated and stored in {} -
'
.
format
(
time
.
strftime
(
"%M:%S"
,
time
.
gmtime
(
elapsed_time
))),
end
=
""
,
flush
=
True
)
print
(
'
Iteration duration: {} - {:.2f} scen/s
'
.
format
(
time
.
strftime
(
"%M:%S"
,
time
.
gmtime
(
elapsed_time
))
,
nb_particles
/
elapsed_time
),
end
=
""
,
flush
=
True
)
# Computing pareto front
start_time
=
time
.
time
()
pareto_mask
=
MCMC
.
is_pareto_efficient
(
scenarios
.
scores
[[
'Resilience'
,
'Proximity'
,
'Productivity'
,
'Biodiversity'
,
'Social'
,
'TargetDelta'
]].
values
)
...
...
scenariosAleatoires/scenarios.py
View file @
c38dfe08
...
...
@@ -72,7 +72,7 @@ class ScenariosStack:
def
reconstitute
(
self
,
iter_nb
,
scenarios_patches
,
scenarios_cult
,
previous_indexes
,
disable_progress
=
False
):
indexes
=
[
next
(
self
.
_counter
)
for
id
in
range
(
len
(
scenarios_cult
))]
self
.
cultgeopat
=
pd
.
DataFrame
(
scenarios_cult
,
index
=
indexes
,
columns
=
self
.
cultgeopat
.
columns
)
self
.
cultgeopat
=
pd
.
DataFrame
(
scenarios_cult
,
index
=
indexes
,
columns
=
self
.
cultgeopat
.
columns
,
dtype
=
'int8'
)
list_scores
=
[]
for
i
,
previous_index
in
tqdm
(
enumerate
(
previous_indexes
),
total
=
len
(
previous_indexes
),
disable
=
disable_progress
):
scenario_patch
=
scenarios_patches
[
i
]
...
...
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