I do not fully understand your question, but it might be connected to Fabian’s question (I have to admit that his title is not helpful to see the connection).
Instead of using the Investment object you can also loop around the parameters to find the best configuration, but you have to looper over the whole creation of the energy system.