Last active
December 18, 2018 06:54
-
-
Save sasamijp/2fe27df9932a8f7c9cb20ba129be736a 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
n = 1000 | |
values = [5+(i**2 % 111) for i in range(1, n+1)] | |
weights = [20+(i % 11) for i in range(1, n+1)] | |
W=800 | |
print("maximize") | |
print("-", " + ".join(str(v)+" x("+str(i+1)+")" for i, v in enumerate(values))) | |
print("subject to") | |
print("c1:", " + ".join(str(w)+" x("+str(i+1)+")" for i, w in enumerate(weights)), "<=", str(W)) | |
print("bounds") | |
print("binary") | |
print(" ".join("x("+str(i)+")" for i in range(1, n+1))) | |
print("end") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment