penal = (P_grid/power_max)**2 ''' P_prod = searev_power(Speed) P_grid = P_prod - P_sto penal = (P_grid / power_max)**2 return penal cost_label = 'quadratic cost' ### Create the system description: searev_sys = SysDescription((3, 1, 1), name='Searev + Storage') searev_sys.dyn = dyn_searev_sto searev_sys.control_box = admissible_controls searev_sys.cost = cost_model searev_sys.perturb_laws = [innov_law] #searev_sys.print_summary() ### Create the DP solver: dpsolv = DPSolver(searev_sys) # discretize the state space N_E = 31 N_S = 61 N_A = 61 S_min, S_max = -4 * .254, 4 * 0.254 A_min, A_max = -4 * .227, 4 * .227 x_grid = dpsolv.discretize_state(0, E_rated, N_E, S_min, S_max, N_S, A_min, A_max, N_A) E_grid, S_grid, A_grid = x_grid # discretize the perturbation
return (x + u - w,) # Attach the dynamical equation to the system description: invsys.dyn = dyn_inv demand_values = [0, 1, 2, 3] demand_proba = [0.2, 0.4, 0.3, 0.1] demand_law = stats.rv_discrete(values=(demand_values, demand_proba)) demand_law = demand_law.freeze() demand_law.pmf([0, 3]) # Probality Mass Function demand_law.rvs(10) # Random Variables generation invsys.perturb_laws = [demand_law] # a list, to support several perturbations def admissible_orders(x): 'interval of allowed orders U(x_k)' U1 = (0, 10) return (U1, ) # tuple, to support several controls # Attach it to the system description. invsys.control_box = admissible_orders ### Cost description g = r(x) + c.u (h,p,c) = 0.5, 3, 1 def op_cost(x,u,w): 'operational cost of the shop' holding = x*h shortage = -x*p
'dynamical equation of the inventory stock `x`. Returns x(k+1).' return (x + u - w, ) # Attach the dynamical equation to the system description: invsys.dyn = dyn_inv demand_values = [0, 1, 2, 3] demand_proba = [0.2, 0.4, 0.3, 0.1] demand_law = stats.rv_discrete(values=(demand_values, demand_proba)) demand_law = demand_law.freeze() demand_law.pmf([0, 3]) # Probality Mass Function demand_law.rvs(10) # Random Variables generation invsys.perturb_laws = [demand_law] # a list, to support several perturbations def admissible_orders(x): 'interval of allowed orders U(x_k)' U1 = (0, 10) return (U1, ) # tuple, to support several controls # Attach it to the system description. invsys.control_box = admissible_orders ### Cost description g = r(x) + c.u (h, p, c) = 0.5, 3, 1
penal = (P_grid/power_max)**2 """ P_prod = searev_power(Speed) P_grid = P_prod - P_sto penal = (P_grid / power_max) ** 2 return penal cost_label = "quadratic cost" ### Create the system description: searev_sys = SysDescription((3, 1, 1), name="Searev + Storage") searev_sys.dyn = dyn_searev_sto searev_sys.control_box = admissible_controls searev_sys.cost = cost_model searev_sys.perturb_laws = [innov_law] # searev_sys.print_summary() ### Create the DP solver: dpsolv = DPSolver(searev_sys) # discretize the state space N_E = 31 N_S = 61 N_A = 61 S_min, S_max = -4 * 0.254, 4 * 0.254 A_min, A_max = -4 * 0.227, 4 * 0.227 x_grid = dpsolv.discretize_state(0, E_rated, N_E, S_min, S_max, N_S, A_min, A_max, N_A) E_grid, S_grid, A_grid = x_grid # discretize the perturbation N_w = 9