popt.cost_functions.ren_npv

Net present value cost function with injection from RENewable energy

 1"Net present value cost function with injection from RENewable energy"
 2
 3import numpy as np
 4
 5
 6def ren_npv(pred_data, kwargs):
 7    """
 8    Net present value cost function with injection from RENewable energy
 9
10    Parameters
11    ----------
12    pred_data_en : ndarray
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        report : list
22            Report dates.
23
24    Returns
25    -------
26    objective_values : ndarray
27        Objective function values (NPV) for all ensemble members.
28    """
29
30    # Get the necessary input
31    keys_opt = kwargs.get('input_dict', {})
32    report = kwargs.get('true_order', [])
33
34    # Economic values
35    npv_const = {}
36    for name, value in keys_opt['npv_const']:
37        npv_const[name] = value
38
39    # Loop over timesteps
40    values = []
41    for i in np.arange(1, len(pred_data)):
42
43        Qop = np.squeeze(pred_data[i]['fopt']) - np.squeeze(pred_data[i - 1]['fopt'])
44        Qgp = np.squeeze(pred_data[i]['fgpt']) - np.squeeze(pred_data[i - 1]['fgpt'])
45        Qwp = np.squeeze(pred_data[i]['fwpt']) - np.squeeze(pred_data[i - 1]['fwpt'])
46
47        Qrenwi = []
48        Qwi = []
49        for key in keys_opt['datatype']:
50            if 'wwit' in key:
51                if 'ren' in key:
52                    Qrenwi.append(np.squeeze(
53                        pred_data[i][key]) - np.squeeze(pred_data[i - 1][key]))
54                else:
55                    Qwi.append(np.squeeze(pred_data[i][key]) -
56                               np.squeeze(pred_data[i - 1][key]))
57        Qrenwi = np.sum(Qrenwi, axis=0)
58        Qwi = np.sum(Qwi, axis=0)
59
60        delta_days = (report[1][i] - report[1][i - 1]).days
61        val = (Qop * npv_const['wop'] + Qgp * npv_const['wgp'] - Qwp * npv_const['wwp'] - Qwi * npv_const['wwi'] -
62               Qrenwi * npv_const['wrenwi']) / (
63            (1 + npv_const['disc']) ** (delta_days / 365))
64
65        values.append(val)
66
67    if 'obj_scaling' in npv_const:
68        return sum(values) / npv_const['obj_scaling']
69    else:
70        return sum(values)
def ren_npv(pred_data, kwargs):
 7def ren_npv(pred_data, kwargs):
 8    """
 9    Net present value cost function with injection from RENewable energy
10
11    Parameters
12    ----------
13    pred_data_en : ndarray
14        Ensemble of predicted data.
15
16    **kwargs : dict
17        Other arguments sent to the npv function
18
19        keys_opt : list
20            Keys with economic data.
21
22        report : list
23            Report dates.
24
25    Returns
26    -------
27    objective_values : ndarray
28        Objective function values (NPV) for all ensemble members.
29    """
30
31    # Get the necessary input
32    keys_opt = kwargs.get('input_dict', {})
33    report = kwargs.get('true_order', [])
34
35    # Economic values
36    npv_const = {}
37    for name, value in keys_opt['npv_const']:
38        npv_const[name] = value
39
40    # Loop over timesteps
41    values = []
42    for i in np.arange(1, len(pred_data)):
43
44        Qop = np.squeeze(pred_data[i]['fopt']) - np.squeeze(pred_data[i - 1]['fopt'])
45        Qgp = np.squeeze(pred_data[i]['fgpt']) - np.squeeze(pred_data[i - 1]['fgpt'])
46        Qwp = np.squeeze(pred_data[i]['fwpt']) - np.squeeze(pred_data[i - 1]['fwpt'])
47
48        Qrenwi = []
49        Qwi = []
50        for key in keys_opt['datatype']:
51            if 'wwit' in key:
52                if 'ren' in key:
53                    Qrenwi.append(np.squeeze(
54                        pred_data[i][key]) - np.squeeze(pred_data[i - 1][key]))
55                else:
56                    Qwi.append(np.squeeze(pred_data[i][key]) -
57                               np.squeeze(pred_data[i - 1][key]))
58        Qrenwi = np.sum(Qrenwi, axis=0)
59        Qwi = np.sum(Qwi, axis=0)
60
61        delta_days = (report[1][i] - report[1][i - 1]).days
62        val = (Qop * npv_const['wop'] + Qgp * npv_const['wgp'] - Qwp * npv_const['wwp'] - Qwi * npv_const['wwi'] -
63               Qrenwi * npv_const['wrenwi']) / (
64            (1 + npv_const['disc']) ** (delta_days / 365))
65
66        values.append(val)
67
68    if 'obj_scaling' in npv_const:
69        return sum(values) / npv_const['obj_scaling']
70    else:
71        return sum(values)

Net present value cost function with injection from RENewable energy

Parameters
  • pred_data_en (ndarray): Ensemble of predicted data.
  • **kwargs (dict): Other arguments sent to the npv function

    keys_opt : list Keys with economic data.

    report : list Report dates.

Returns
  • objective_values (ndarray): Objective function values (NPV) for all ensemble members.