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

better progression output for MCMC

parent b73f7cdc
......@@ -106,7 +106,7 @@ class MCMC:
pareto_mask = MCMC.is_pareto_efficient(scenarios.scores[['Resilience','Proximity','Productivity','Biodiversity','Social','TargetDelta']].values)
scenarios.scores['pareto'] = pareto_mask
elapsed_time = time.time() - start_time
print('Pareto front computed in {} - '.format(time.strftime("%M:%S", time.gmtime(elapsed_time))), end="", flush=True)
print('Pareto front computed ({:.2f}% keeped) in {} - '.format(100*np.sum(pareto_mask)/len(pareto_mask), time.strftime("%M:%S", time.gmtime(elapsed_time))), end="", flush=True)
# Writing output data
start_time = time.time()
scenarios.scores.to_csv(self.outputdir+'/scores_iter_{0:03d}.csv'.format(iter_nb), index=True)
......@@ -122,15 +122,17 @@ class MCMC:
# and an error is triggered. Here, we ignore this error.
pass
elapsed_time = time.time() - start_time
print('Scores written in {} '.format(time.strftime("%M:%S", time.gmtime(elapsed_time))), end="", flush=True)
print('Scores of {} scenarios written in {} '.format(len(scenarios.scores), time.strftime("%M:%S", time.gmtime(elapsed_time))), end="", flush=True)
print()
# Retaining only optimal particules
scenarios.retain(pareto_mask)
if write_data:
print(' Writing modified patches of scenarios')
# Writing shapefiles
start_time = time.time()
shp_dir = self.outputdir + '/patches_iter_{0:03d}'.format(iter_nb)
os.makedirs(shp_dir)
for index,scenario in scenarios.cultgeopat.iterrows():
for index,scenario in tqdm(scenarios.cultgeopat.iterrows(), total=len(scenarios.cultgeopat)):
concat = pd.concat([self.patches, scenario.to_frame("newcult")], axis=1)
concat = concat[concat['init_cult']!=concat['newcult']]
if len(concat)>0:
......@@ -139,8 +141,7 @@ class MCMC:
concat.to_file(shp_dir+'/{:03d}_{}'.format(iter_nb, index), encoding='utf-8')
# scenario[scenario['cultmodified']].drop('cultmodified', axis=1).to_file(shp_dir+'/{0:03d}_{}'.format(iter_nb,index), encoding='utf-8')
elapsed_time = time.time() - start_time
print(' - Shape files written in {}'.format(time.strftime("%M:%S", time.gmtime(elapsed_time))), end="", flush=True)
print()
print(' Shape files written in {}'.format(time.strftime("%M:%S", time.gmtime(elapsed_time))))
return scenarios
def run(self):
......
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