Commit c38dfe08 authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

Building dataframe from geoseries instead of list and dtype fixed

parent 467a8e7a
......@@ -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)
......
......@@ -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]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment