Created
December 9, 2015 16:26
-
-
Save barelyknown/e3c1350a81a47b0402c6 to your computer and use it in GitHub Desktop.
optimize-roster-2.js
This file contains hidden or 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 addSalaryCapConstraint(engine) { | |
// add a constraint for the overall salary cap | |
var salaryCapConstraint = engine.addConstraint(0, SALARY_CAP); | |
// for each player | |
for (var row = 1; row <= PLAYERS.getNumRows(); row++) { | |
var player = PLAYERS.getCell( | |
row, | |
PLAYERS_PLAYER_COLUMN | |
).getValue(); | |
var playerSalary = PLAYERS.getCell( | |
row, | |
PLAYERS_SALARY_COLUMN | |
).getValue(); | |
// add the player's salary to the constraint | |
salaryCapConstraint.setCoefficient(player, playerSalary); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment