Skip to content

Commit

Permalink
Still unfeasible results, releasing with a warning
Browse files Browse the repository at this point in the history
  • Loading branch information
davidusb-geek committed Jun 2, 2024
1 parent 20b9d60 commit e666fdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 3 additions & 1 deletion scripts/script_debug_optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@
}

# Set special debug cases
optim_conf.update({'lp_solver': 'PULP_CBC_CMD'}) # set the name of the linear programming solver that will be used. Options are 'PULP_CBC_CMD', 'GLPK_CMD' and 'COIN_CMD'.
optim_conf.update({'lp_solver_path': 'empty'}) # set the path to the LP solver, COIN_CMD default is /usr/bin/cbc
optim_conf.update({'treat_def_as_semi_cont': [True, True]})
optim_conf.update({'set_def_constant': [False, False]})
optim_conf.update({'P_deferrable_nom': [[500.0, 1000.0, 1000.0, 500.0], 750.0]})
optim_conf.update({'P_deferrable_nom': [[500.0, 100.0, 100.0, 500.0], 750.0]})

optim_conf.update({'set_use_battery': False})
optim_conf.update({'set_nocharge_from_grid': False})
Expand Down
26 changes: 13 additions & 13 deletions src/emhass/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ def perform_optimization(self, data_opt: pd.DataFrame, P_PV: np.array, P_load: n
P_deferrable = []
P_def_bin1 = []
for k in range(self.optim_conf['num_def_loads']):
if type(self.optim_conf['P_deferrable_nom'][k]) == list:
upBound = np.max(self.optim_conf['P_deferrable_nom'][k])
else:
upBound = self.optim_conf['P_deferrable_nom'][k]
if self.optim_conf['treat_def_as_semi_cont'][k]:
P_deferrable.append({(i):plp.LpVariable(cat='Continuous',
name="P_deferrable{}_{}".format(k, i)) for i in set_I})
else:
if type(self.optim_conf['P_deferrable_nom'][k]) == list:
upBound = np.max(self.optim_conf['P_deferrable_nom'][k])
else:
upBound = self.optim_conf['P_deferrable_nom'][k]
P_deferrable.append({(i):plp.LpVariable(cat='Continuous',
lowBound=0, upBound=upBound,
name="P_deferrable{}_{}".format(k, i)) for i in set_I})
Expand Down Expand Up @@ -334,26 +334,26 @@ def create_matrix(input_list, n):
return matrix
matrix = create_matrix(power_sequence, n-sequence_length)
y = plp.LpVariable.dicts(f"y{k}", (i for i in range(len(matrix))), cat='Binary')
constraints.update({f"SingleValueConstraint_{i}" :
constraints.update({f"single_value_constraint_{k}" :
plp.LpConstraint(
e = plp.lpSum(y[i] for i in range(len(matrix))) - 1,
sense = plp.LpConstraintEQ,
rhs = 0)
})
# constraints.update({f"pdef{k}_sumconstraint_{i}" :
# plp.LpConstraint(
# e = plp.lpSum(P_deferrable[k][i] for i in set_I) - np.sum(power_sequence),
# sense = plp.LpConstraintEQ,
# rhs = 0)
# })
constraints.update({f"pdef{k}_positiveconstraint_{i}" :
constraints.update({f"pdef{k}_sumconstraint_{i}" :
plp.LpConstraint(
e = plp.lpSum(P_deferrable[k][i] for i in set_I) - np.sum(power_sequence),
sense = plp.LpConstraintEQ,
rhs = 0)
})
constraints.update({f"pdef{k}_positive_constraint_{i}" :
plp.LpConstraint(
e = P_deferrable[k][i],
sense = plp.LpConstraintGE,
rhs = 0)
for i in set_I})
for num, mat in enumerate(matrix):
constraints.update({f"pdef{k}_valueconstraint_{num}_{i}" :
constraints.update({f"pdef{k}_value_constraint_{num}_{i}" :
plp.LpConstraint(
e = P_deferrable[k][i] - mat[i]*y[num],
sense = plp.LpConstraintEQ,
Expand Down

0 comments on commit e666fdd

Please sign in to comment.