convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

Maximizing Sums #1469

Closed adishavit closed 4 years ago

adishavit commented 4 years ago

I need to maximize the sum of bounded (constrained) variables. The objective minimizes and the docs say that to maximize I need to take reciprocal. However I cannot create the reciprocal of a sum (posynomial). I can minimize the sum of element reciprocals but this isn’t exactly what I need to maximize.

Is there some other transformation/method I should use?

rileyjmurray commented 4 years ago

When it comes to geometric programs, there is no efficient algorithm that can handle maximization of a sum of decision variables. You can equivalently frame the problem as minimizing a negated sum -x - y - z ..... When trying to minimize such a function in the geometric-programming framework, you have started to talk about "signomial programs." GPKit has functionality for finding locally optimal solutions to signomial programs-- this is described a bit in the web documentation.

1ozturkbe commented 4 years ago

@rileyjmurray is right, unfortunately there is not clean way to do this. A hacky alternative to try is to min 1/prod(vars). Obviously this is not the same as a sum, so your experience may vary.

adishavit commented 4 years ago

Yes. I tried both min(1/prod(vars)) and min(sum(1/var_i)).

1ozturkbe commented 4 years ago

Results? I'm assuming it didn't work. What you need is signomials:

with SignomialsEnabled():
    constraints += [obj<= sum(vars)]
m = Model(1/obj, constraints)
adishavit commented 4 years ago

Actually, my use case is relatively easy (like DP with external some quadratic constraints) so both approaches seemed to work on my initial tests. I will need further analysis with more rigorous test to see it fail.
I will try your suggested Signomial approach which does seem to minimize the correct thing, I just hope it will not run much longer.

bqpd commented 4 years ago

Good luck!