Last active
September 26, 2022 21:35
-
-
Save medewitt/0941ed3fa9b100f8904003803fbb678f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Purpose: This is just a play model to think about time spent on large and big grants/opportunities and | |
# overall likelihood of a successful result (undefined, just general feel). | |
# 2080 is the hours in a year if working 40 hours (because everyone does that...) | |
using JuMP | |
using Ipopt | |
model = Model(Ipopt.Optimizer) | |
p1 = .05 # Probability of winning grant 1 | |
sx1 = .4 # Probability of successful work (class 1) | |
sx2 = .85 # Probability of successful work (class 2) | |
""" | |
maximize x*p1*sx1 + y * p2*sx2 (probability of a successful project) | |
s.t. | |
# Time to building proposals (i.e. 160 per small, 320 per large, work = time * success*number) | |
x * 160 + y * 320 + p1*x*400 + p2*y*1000 <= 2080 | |
# No more than 12 small opportunities, no more than 5 large opportunities | |
12 >= x >= 0 | |
5 >= y >= 0 | |
p1 = .1 | |
p2 = .01 | |
""" | |
@variable(model, 12 >= x >= 0) | |
@variable(model, 5 >= y >= 0) | |
@variable(model, p2 >=.01) | |
@objective(model, Max, x*p1*sx1 + y * p2*sx2) | |
@constraint(model, c1, x * 160 + y * 320 + p1*x*400 + p2*y*1000 <= 2080) | |
@constraint(model, c2, p2 == .01) | |
print(model) | |
optimize!(model) | |
@show termination_status(model) | |
@show primal_status(model) | |
@show dual_status(model) | |
@show objective_value(model) | |
println("apply to:", round(value(x)), " small grants\napply to:", round(value(y))," large grants") | |
println("Win: ",round(value(x)*p1, digits = 2), " small grants") | |
println("Win: ",round(value(y)*value(p2), digits = 2), " large grants") | |
println("success probability: ", round(objective_value(model)*100),"%") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
apply to:12.0 small grants
apply to:0.0 large grants
Win: 0.58 small grants
Win: 0.0 large grants
success probability: 23.0%