2

I'm trying to solve a linearized DEA optimization problem.

Here is how I defined the problem in python:

Philadelphia = plp.LpProblem("Philadelphia", plp.LpMaximize)
U1 = plp.LpVariable("U1", 0)
U2 = plp.LpVariable("U2", 0)
V1 = plp.LpVariable("V1", 0)
V2 = plp.LpVariable("V2", 0)
Philadelphia += 700*U1 + 300*U2, "obj"
Philadelphia += 700*U1 + 300*U2 - 40*V1 - 500*V2 <= 0, "c1"
Philadelphia += 300*U1 + 600*U2 - 50*V1 - 500*V2 <= 0, "c2"
Philadelphia += 200*U1 + 700*U2 - 50*V1 - 400*V2 <= 0, "c3"
Philadelphia += 400*U1 + 600*U2 - 50*V1 - 500*V2 <= 0, "c4"
Philadelphia += 500*U1 + 400*U2 - 40*V1 - 400*V2 <= 0, "c5"
Philadelphia += 500*U1 + 500*U2 - 50*V1 - 500*V2 <= 0, "c6"
Philadelphia += 800*U1 + 500*U2 - 40*V1 - 600*V2 <= 0, "c7"
Philadelphia += 300*U1 + 200*U2 - 30*V1 - 400*V2 <= 0, "c8"
Philadelphia += 40*V1 + 500*V2 = 1, "c9"

However, the constraint:

Philadelphia += 40*V1 + 500*V2 = 1, "c9"

Gives the error "invalid syntax" with an arrow pointing to the equals sign.

How can I modify my constraint so that I do not get this error?

MrFlom
  • 99
  • 10
  • 1
    ... that is not valid Python syntax. What exactly are you trying to do? – Cory Kramer Sep 23 '14 at 20:59
  • 3
    For the love of everything, **edit the question**. See http://stackoverflow.com/help/mcve – jonrsharpe Sep 23 '14 at 21:01
  • @Cyber This is valid code (though the example could have been made with less constraints). It uses a linear programming library known as PuLP and expects this syntax. – Mike Sep 23 '14 at 21:25

1 Answers1

1

PuLP syntax needs == for forcing equality.

Philadelphia += 40*V1 + 500*V2 == 1, "c9"

That should work!

Mike
  • 6,813
  • 4
  • 29
  • 50