Commit 18d05f66 authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

indicator changed from minimization to maximisation

parent 6e4c1f4d
...@@ -43,13 +43,16 @@ class Social: ...@@ -43,13 +43,16 @@ class Social:
# patches that have different farming that others of the same farmer # patches that have different farming that others of the same farmer
if row['cultgeopat_y'] not in filter1[filter1['id_expl']==row['id_expl']]['cultgeopat_x']: if row['cultgeopat_y'] not in filter1[filter1['id_expl']==row['id_expl']]['cultgeopat_x']:
cost += self.matrice_transition[row['cultgeopat_x']][row['cultgeopat_y']] cost += self.matrice_transition[row['cultgeopat_x']][row['cultgeopat_y']]
return cost return 1/(1+cost)
if __name__ == '__main__': if __name__ == '__main__':
import geopandas as gpd import geopandas as gpd
patches = gpd.GeoDataFrame.from_file("../output/PAT_patches/PAT_patches.shp", encoding='utf-8') patches = gpd.GeoDataFrame.from_file("../output/PAT_patches/PAT_patches.shp", encoding='utf-8')
social = Social(patches, '../resources/matrice_transition.csv', 0.1)
scenario_patches = patches.copy() scenario_patches = patches.copy()
print(social.compute_indicator(scenario_patches))
scenario_patches.ix[2,'cultgeopat']='Protéagineux' scenario_patches.ix[2,'cultgeopat']='Protéagineux'
social = Social(patches, '../resources/matrice_transition.csv', 0.1)
print(social.compute_indicator(scenario_patches)) print(social.compute_indicator(scenario_patches))
# should give 0.5 the cost for one transition to Protéagineux # should give 0.5 the cost for one transition to Protéagineux
scenario_patches['cultgeopat']='Fruits et légumes'
print(social.compute_indicator(scenario_patches))
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