# Pyomo: Help setting up my model

I have been working with a model for the past couple of weeks, but I am not sure what am I doing wrong as every time Pyomo returns that is infeasible or unbounded. I am trying to model an Electric Vehicle scheduling to minimise the electricity bill of a house. The house has a PV generation system connected as well. The EV is able to charge and give energy to the house if required everytime that is plugged, i.e. avail = 1 and and only discharge when is driving, i.e. avail=0. The model is capable to sell energy back to the grid as well which also helps to reduce the electricity bill even more.

I already figured out how to prevent charging when avail=0 (driving) in another question https://stackoverflow.com/questions/62406319/pyomo-struggling-to-get-a-constraint-to-work/62406945#62406945 which is great. But now the problem is that because the model is considering that the energy used when driving is the same as if it was selling it back to the grid, the results are not realistic at all.

Also I am not sure if the optimisation is correct as the model is ignoring the house demand when the EV is not available (avail=0). As I explained in my previous question, I am considering this model as a stationary battery that connects and disconnects, however, at this point I am not sure if it is correct that way.

At the moment, load contains both the house and EV demand.

net_demand = load-PV
for j, e in enumerate(net):
if e >= 0:
else:



I would like to keep them each in separate dictionaries, which I guess it will help me to keep the house drawing energy from the grid or PV even if the EV is driving (avail=0) but I am not sure how to formulate it.

Here is the rest of the code so far:

As I mentioned, availDict = dict(enumerate(df[avail])) has values avail=1 (plugged) and avail=0 (not plugged and driving).

I hope that I explained my problem properly and hopefully you are able to understand what I meant.

If there is another suggestion or you need more information please let me know so I can provide it as soon as possible.

Thanks