def run_scenarios_floods(costs_all,link,exanteinterv):
	out = DataFrame(columns=['intervention','redirection','proba','length','user_annual_losses','expost_annual_losses'])
	climat = 'EU_historical'
	for climat in ['EU_historical','GFDL_8.5','HadGEM2_8.5','IPSL_8.5']:
		for redirection in [0,1,2]:
			for length in [2,1,0.5]:
				for proba in [1,2]:
					summary = summarize_costs_floods(link,costs_all,climat,redirection,length,proba,exanteinterv)
					out.loc[len(out),:]=[exanteinterv,redirection,proba,length]+annual_losses_floods(summary)
	return out
def run_scenarios_with_interv(costs_all,link,interv,expost_intervention=False):
    out = DataFrame(columns=['intervention','redirection','climat','length','exp_annual_losses'])

    for redirection in [0,1,2]:
        for climat in ['EU_historical','GFDL_8.5','HadGEM2_8.5','IPSL_8.5']:
            for length in [2,1,0.5]:
                new_losses = annual_losses_with_interv(link,costs_all,interv,climat,redirection,length,expost_intervention)
                out.loc[len(out),:]=[interv,redirection,climat,length,\
                                    new_losses]
    return out
def vo_all(R,losses_wetlands):
	out=DataFrame(columns=['wetland_loss','option_value','risk_premium'])
	for wetlandloss in [0,10,50,70]:
		funcy = lambda c : np.mean(np.log(R-losses_wetlands['100wetlandloss']+c))-np.mean(np.log(R-losses_wetlands['{}wetlandloss'.format(wetlandloss)]))
		c_initial_guess = np.mean(losses_wetlands['{}wetlandloss'.format(wetlandloss)])
		result,info,ier,msg = fsolve(funcy, c_initial_guess,full_output=True)
		if ier!=1:
			vo=0
		else:
			vo=result[0]
		rp=vo-(np.mean(losses_wetlands['100wetlandloss'])-np.mean(losses_wetlands['{}wetlandloss'.format(wetlandloss)]))
		out.loc[len(out),:]=[wetlandloss,vo,rp]
	return out
def run_scenarios_huaycos(costs_all,link,h_proba,exanteinterv,duration_huaycos):

	out = DataFrame(columns=['intervention','duration_huaycos','user_annual_losses','expost_annual_losses'])
	new_losses = h_proba*costs_huaycos(link,costs_all,duration_huaycos,exanteinterv).values[0]
	out.loc[len(out),:]=[exanteinterv,duration_huaycos]+list(new_losses)
	return out