popt.cost_functions.npv
Net present value.
1"""Net present value.""" 2import numpy as np 3 4 5def npv(pred_data, **kwargs): 6 """ 7 Net present value cost function 8 9 Parameters 10 ---------- 11 pred_data : array_like 12 Ensemble of predicted data. 13 14 **kwargs : dict 15 Other arguments sent to the npv function 16 17 keys_opt : list 18 Keys with economic data. 19 20 - wop: oil price 21 - wgp: gas price 22 - wwp: water production cost 23 - wwi: water injection cost 24 - disc: discount factor 25 - obj_scaling: used to scale the objective function (negative since all methods are minimizers) 26 27 report : list 28 Report dates. 29 30 Returns 31 ------- 32 objective_values : numpy.ndarray 33 Objective function values (NPV) for all ensemble members. 34 """ 35 36 # Get the necessary input 37 keys_opt = kwargs.get('input_dict',{}) 38 report = kwargs.get('true_order', []) 39 40 # Economic values 41 npv_const = {} 42 for name, value in keys_opt['npv_const']: 43 npv_const[name] = value 44 45 values = [] 46 for i in np.arange(1, len(pred_data)): 47 48 Qop = np.squeeze(pred_data[i]['fopt']) - np.squeeze(pred_data[i - 1]['fopt']) 49 Qgp = np.squeeze(pred_data[i]['fgpt']) - np.squeeze(pred_data[i - 1]['fgpt']) 50 Qwp = np.squeeze(pred_data[i]['fwpt']) - np.squeeze(pred_data[i - 1]['fwpt']) 51 Qwi = np.squeeze(pred_data[i]['fwit']) - np.squeeze(pred_data[i - 1]['fwit']) 52 delta_days = (report[1][i] - report[1][i - 1]).days 53 54 val = (Qop * npv_const['wop'] + Qgp * npv_const['wgp'] - Qwp * npv_const['wwp'] - Qwi * npv_const['wwi']) / ( 55 (1 + npv_const['disc']) ** (delta_days / 365)) 56 57 values.append(val) 58 59 if 'obj_scaling' in npv_const: 60 return np.array(sum(values)) / npv_const['obj_scaling'] 61 else: 62 return np.array(sum(values))
def
npv(pred_data, **kwargs):
6def npv(pred_data, **kwargs): 7 """ 8 Net present value cost function 9 10 Parameters 11 ---------- 12 pred_data : array_like 13 Ensemble of predicted data. 14 15 **kwargs : dict 16 Other arguments sent to the npv function 17 18 keys_opt : list 19 Keys with economic data. 20 21 - wop: oil price 22 - wgp: gas price 23 - wwp: water production cost 24 - wwi: water injection cost 25 - disc: discount factor 26 - obj_scaling: used to scale the objective function (negative since all methods are minimizers) 27 28 report : list 29 Report dates. 30 31 Returns 32 ------- 33 objective_values : numpy.ndarray 34 Objective function values (NPV) for all ensemble members. 35 """ 36 37 # Get the necessary input 38 keys_opt = kwargs.get('input_dict',{}) 39 report = kwargs.get('true_order', []) 40 41 # Economic values 42 npv_const = {} 43 for name, value in keys_opt['npv_const']: 44 npv_const[name] = value 45 46 values = [] 47 for i in np.arange(1, len(pred_data)): 48 49 Qop = np.squeeze(pred_data[i]['fopt']) - np.squeeze(pred_data[i - 1]['fopt']) 50 Qgp = np.squeeze(pred_data[i]['fgpt']) - np.squeeze(pred_data[i - 1]['fgpt']) 51 Qwp = np.squeeze(pred_data[i]['fwpt']) - np.squeeze(pred_data[i - 1]['fwpt']) 52 Qwi = np.squeeze(pred_data[i]['fwit']) - np.squeeze(pred_data[i - 1]['fwit']) 53 delta_days = (report[1][i] - report[1][i - 1]).days 54 55 val = (Qop * npv_const['wop'] + Qgp * npv_const['wgp'] - Qwp * npv_const['wwp'] - Qwi * npv_const['wwi']) / ( 56 (1 + npv_const['disc']) ** (delta_days / 365)) 57 58 values.append(val) 59 60 if 'obj_scaling' in npv_const: 61 return np.array(sum(values)) / npv_const['obj_scaling'] 62 else: 63 return np.array(sum(values))
Net present value cost function
Parameters
- pred_data (array_like): Ensemble of predicted data.
**kwargs (dict): Other arguments sent to the npv function
keys_opt : list Keys with economic data.
- wop: oil price - wgp: gas price - wwp: water production cost - wwi: water injection cost - disc: discount factor - obj_scaling: used to scale the objective function (negative since all methods are minimizers)
report : list Report dates.
Returns
- objective_values (numpy.ndarray): Objective function values (NPV) for all ensemble members.