cluster_network: Fix distribute_clusters_optim for high numbers of clusters
distribute_clusters_optim should never try to assign more clusters to a (country, sub_network) than there are substations there.
This commit is contained in:
parent
6feebedc0d
commit
39cb17a7a1
@ -96,8 +96,12 @@ def distribute_clusters_optim(n, n_clusters, solver_name=None):
|
||||
.groupby([n.buses.country, n.buses.sub_network]).sum()
|
||||
.pipe(normed))
|
||||
|
||||
N = n.buses.groupby(['country', 'sub_network']).size()
|
||||
|
||||
m = po.ConcreteModel()
|
||||
m.n = po.Var(list(L.index), bounds=(1, None), domain=po.Integers)
|
||||
def n_bounds(model, *n_id):
|
||||
return (1, N[n_id])
|
||||
m.n = po.Var(list(L.index), bounds=n_bounds, domain=po.Integers)
|
||||
m.tot = po.Constraint(expr=(po.summation(m.n) == n_clusters))
|
||||
m.objective = po.Objective(expr=po.sum((m.n[i] - L.loc[i]*n_clusters)**2
|
||||
for i in L.index),
|
||||
|
Loading…
Reference in New Issue
Block a user