# Newbie Looking for Help - Code failing after adjusting constraints

Background - I am new at this and I didnt stay at a Holiday Inn Express last night, so I am struggling. I am using Julia/Jump code to Optimize lineup for Daily Fatasy Hockey with moderate success. I am working to convert the code to new constraints to support baseball and failing miserably.

I started off attempting to fully re-write the code, but was unable to isolate my errors to solve them. Now I am converting it one constrain at a time. I have it running, but not following the constraint as I believe it is designed.

The code below is going to look like it is for hockey, which it is and working well - but I have modified the goalie constraint from 1 to 2 to replicate the DFS baseball structure which utilizes 2 pitchers. However, when I execute the code - I only get one goalie (“aka pitcher” in the output file. Not sure why!!! Please help

Obviously some additional files needed to execute this, which I have and can share if someone is curious enough to want to help me solve

The original code was developed and shared as part of a paper disclosed here http://arxiv.org/pdf/1604.01455v2.pdf

``````# This is a function that creates one lineup using the No Stacking formulation function
# one_lineup_no_stacking(skaters, goalies, lineups, num_overlap, num_skaters, num_goalies, centers,
# wingers, defenders, num_teams, skaters_teams, goalie_opponents, team_lines, num_lines, P1_info)
m = Model(solver=GLPKSolverMIP())

# Variable for skaters in lineup.
@variable(m, skaters_lineup[i=1:num_skaters], Bin)

# Variable for goalie in lineup.
@variable(m, goalies_lineup[i=1:num_goalies], Bin)

# Two goalie constraint
@constraint(m, sum{goalies_lineup[i], i=1:num_goalies} == 2)

# Eight Skaters constraint
@constraint(m, sum{skaters_lineup[i], i=1:num_skaters} == 8)

# between 2 and 3 centers
@constraint(m, sum{centers[i]*skaters_lineup[i], i=1:num_skaters} <= 3)
@constraint(m, 2 <= sum{centers[i]*skaters_lineup[i], i=1:num_skaters})

# between 3 and 4 wingers
@constraint(m, sum{wingers[i]*skaters_lineup[i], i=1:num_skaters} <= 4)
@constraint(m, 3<=sum{wingers[i]*skaters_lineup[i], i=1:num_skaters})

# between 2 and 3 defenders
@constraint(m, 2 <= sum{defenders[i]*skaters_lineup[i], i=1:num_skaters})
@constraint(m, sum{defenders[i]*skaters_lineup[i], i=1:num_skaters} <= 3)

# Financial Constraint
@constraint(m, sum{skaters[i,:Salary]*skaters_lineup[i], i=1:num_skaters} + sum{goalies[i,:Salary]*goalies_lineup[i], i=1:num_goalies} <= 50000)

# at least 3 different teams for the 8 skaters constraints
@variable(m, used_team[i=1:num_teams], Bin)
@constraint(m, constr[i=1:num_teams], used_team[i] <= sum{skaters_teams[t, i]*skaters_lineup[t], t=1:num_skaters})
@constraint(m, sum{used_team[i], i=1:num_teams} >= 3)

# Overlap Constraint
@constraint(m, constr[i=1:size(lineups)[2]], sum{lineups[j,i]*skaters_lineup[j], j=1:num_skaters} + sum{lineups[num_skaters+j,i]*goalies_lineup[j], j=1:num_goalies} <= num_overlap)

# Objective
@objective(m, Max, sum{skaters[i,:Projection]*skaters_lineup[i], i=1:num_skaters} + sum{goalies[i,:Projection]*goalies_lineup[i], i=1:num_goalies})

# Solve the integer programming problem
println("Solving Problem...")
@printf("\n")
status = solve(m);

# Puts the output of one lineup into a format that will be used later
if status==:Optimal
skaters_lineup_copy = Array(Int64, 0)
for i=1:num_skaters
if getvalue(skaters_lineup[i]) >= 0.9 && getvalue(skaters_lineup[i]) <= 1.1
skaters_lineup_copy = vcat(skaters_lineup_copy, fill(1,1))
else
skaters_lineup_copy = vcat(skaters_lineup_copy, fill(0,1))
end
end
for i=1:num_goalies
if getvalue(goalies_lineup[i]) >= 0.9 && getvalue(goalies_lineup[i]) <= 1.1
skaters_lineup_copy = vcat(skaters_lineup_copy, fill(1,1))
else
skaters_lineup_copy = vcat(skaters_lineup_copy, fill(0,1))
end
end
return(skaters_lineup_copy)
end
``````

end

< I am giving guidance – the csv datafiles were malformed >