Created
December 9, 2015 16:25
-
-
Save barelyknown/a5f8ac12ec29451afd1b to your computer and use it in GitHub Desktop.
optimize-roster-0.js
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
function addVariables(engine) { | |
// for each player | |
for (var row = 1; row <= PLAYERS.getNumRows(); row++) { | |
var player = PLAYERS.getCell( | |
row, | |
PLAYERS_PLAYER_COLUMN | |
).getValue(); | |
var projectedPoints = PLAYERS.getCell( | |
row, PLAYERS_PROJECTED_POINTS_COLUMN | |
).getValue(); | |
// add a variable for the player that enables them | |
// to be selected (1) or not selected (0) | |
engine.addVariable( | |
player, | |
0, | |
1, | |
LinearOptimizationService.VariableType.INTEGER | |
); | |
// set the projected points as the coefficient for | |
// the player's variable | |
engine.setObjectiveCoefficient(player, projectedPoints); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment