this repo has no description
1# A political problem 2 3# Suppose that you are a politician trying to win an election. Your district has three 4# different types of areas - urban, suburban, and rural. These areas have, respectively, 5# 100,000, 200,000, and 50,000 registered voters. Although not all the registered voters 6# actually go to the polls, you decide that to govern effectively, you would like at least 7# half the registered voters in each of the three regions to vote for you. You are honorable 8# and would never consider supporting policies in which you do not believe. You realize, 9# however, that certain issues may be more effective in winning votes in certain places. 10# Your primary issues are building more roads, gun control, farm subsidies, and a gasoline tax 11# dedicated to improved public transit. 12# According to your campaign staff's research, you can estimate how many votes you win or lose 13# from each population segment by spending $1,000 on advertising on each issue. 14# POLICY | URBAN SUBURBAN RURAL 15# ----------------------------------------- 16# build roads | -2 5 3 17# gun control | 8 2 -5 18# farm subsidies | 0 0 10 19# gasoline tax | 10 0 -2 20# 21# In this table, each entry indicates the number of thousands of either urban, suburban, 22# or rural voters who would be won over by spending $1,000 on advertising in support of 23# a particular issue. Negative entries denote votes that would be lost. 24# Your task is to figure out the minimum amount of mony that you need to spend in order to win 25# 50,000 urban votes, 10,000 suburban votes, and 25,000 rural votes. 26 27 28from minizinc import * 29 30m = Model() 31 32x1 = m.Variable(0.0,10000.0) 33x2 = m.Variable(0.0,10000.0) 34x3 = m.Variable(0.0,10000.0) 35x4 = m.Variable(0.0,10000.0) 36 37m.Constraint( -2.0*x1 + 8.0*x2 + 0.0*x3 + 10.0*x4 >= 50.0, 38 5.0*x1 + 2.0*x2 + 0.0*x3 + 0.0*x4 >= 100.0, 39 3.0*x1 - 5.0*x2 + 10.0*x3 - 2.0*x4 >= 25.0, 40 ) 41 42m._debugprint() 43m.mznmodel.set_time_limit(10) 44 45m.minimize(x1+x2+x3+x4) 46 47m.next() 48 49print "Minimize cost = ", x1 + x2 + x3 + x4 50print "where x1 = ", x1 51print " x2 = ", x2 52print " x3 = ", x3 53print " x4 = ", x4