Created
May 9, 2015 05:36
-
-
Save logworthy/8ff6ea59e567266e2bf6 to your computer and use it in GitHub Desktop.
linear programming example
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
/***** | |
EXAMPLE OF A LINEAR PROGRAMMING PROBLEM | |
*****/ | |
/* classes of things */ | |
set CATEGORIES; | |
/* function discretised over these points */ | |
set POINTS; | |
/* hack to set points to point values */ | |
param POINT_VALUES {p in POINTS} := p; | |
/* value of applying a particular point to a particular categoy */ | |
param POINT_OUTCOME_PRIMARY {c in CATEGORIES, p in POINTS}; | |
/* value of applying a particular point to a particular categoy */ | |
param POINT_OUTCOME_SECONDARY {c in CATEGORIES, p in POINTS}; | |
/* apply this point to this category */ | |
var category_point{c in CATEGORIES, p in POINTS} binary; | |
maximize value: sum{c in CATEGORIES, p in POINTS} category_point[c,p] * POINT_OUTCOME_PRIMARY[c,p] + sum{c in CATEGORIES, p in POINTS} category_point[c,p] * POINT_OUTCOME_SECONDARY[c,p]; | |
one_point_per_category {c in CATEGORIES}: sum{p in POINTS} category_point[c,p] = 1; | |
positive_primary_outcome: sum{c in CATEGORIES, p in POINTS} category_point[c,p] * POINT_OUTCOME_PRIMARY[c,p] >= 0; | |
positive_secondary_outcome: sum{c in CATEGORIES, p in POINTS} category_point[c,p] * POINT_OUTCOME_SECONDARY[c,p] >= 0; | |
data; | |
set CATEGORIES := A B C D; | |
set POINTS := 1 2 3 4 5; | |
param POINT_OUTCOME_PRIMARY := | |
[A, 1] 44 | |
[A, 2] 43 | |
[A, 3] -32 | |
[A, 4] -23 | |
[A, 5] 18 | |
[B, 1] 34 | |
[B, 2] -18 | |
[B, 3] -32 | |
[B, 4] -31 | |
[B, 5] -41 | |
[C, 1] -13 | |
[C, 2] -13 | |
[C, 3] 48 | |
[C, 4] -42 | |
[C, 5] 29 | |
[D, 1] 4 | |
[D, 2] -50 | |
[D, 3] 32 | |
[D, 4] 7 | |
[D, 5] 7; | |
param POINT_OUTCOME_SECONDARY := | |
[A, 1] 0 | |
[A, 2] -28 | |
[A, 3] 26 | |
[A, 4] -4 | |
[A, 5] 43 | |
[B, 1] -24 | |
[B, 2] -49 | |
[B, 3] -47 | |
[B, 4] -45 | |
[B, 5] -36 | |
[C, 1] 50 | |
[C, 2] 4 | |
[C, 3] -11 | |
[C, 4] 34 | |
[C, 5] -48 | |
[D, 1] 24 | |
[D, 2] 25 | |
[D, 3] 3 | |
[D, 4] 40 | |
[D, 5] -27; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment