Modelling powerlines with negative costs

Hi all,

I am attaching a modified code of the provided “dispatch.py” example, in order to show the problem I have encountered.

It concerns the use of negative costs. In particular, if I associate a negative cost (which are of interest for my work on energy communities and sharing of electricity) with the powerlines (Link component), it happens the following: between the nodes involved in the bidirectional exchange, an amount of energy equal to the nominal capacity (500) is exchanged every hour, even if this energy is not produced/purchased.

Any suggestion on a possible solution?

Thanks!
Valeria

dispatch.txt (7.3 KB)