Question: Fix this LINGO code so that it selects the players with the highest weights based on the salary and position constraints. The goal is to

Fix this LINGO code so that it selects the players with the highest weights based on the salary and position constraints. The goal is to have the program pick the players with the highest weights based in the given constraints and then multiply that be either 1 or 0. There should be only 4 Centers with a selected value of 1 the rest should be 0, same for LW and RW, only 6 D with a selected value of 1 and only 2 goalies with a selected value of 1. The solution report should keep the weights and caphit of each player the same as in the excel sheet and only the "selected" variable will change (to either a 1 or 0, based on if the player was selected. Therefore only the players selected for the team will have a 1 next to them in the solution report and everyone will have a 0.
sets:
Player/P1..P292/;
Position/C,D,LW,RW,G/;
OnRoster(Player,Position):weight,caphit,selected;
endsets
data:
weight = @OLE('C:\Users\ColeW\OneDrive\Desktop\playerstats Lingo.xlsx','C2:G293');
caphit = @OLE('C:\Users\ColeW\OneDrive\Desktop\playerstats Lingo.xlsx','H2:L293');
enddata
max = maxweight;
maxweight = @sum(OnRoster(i,j): weight(i,j)*selected(i,j));
@for(Player(i): @sum(Position(j): selected(i,j))<=1);
@sum(OnRoster(i,j): caphit(i,j)*selected(i,j))<=83500000;
@sum(OnRoster(i,j)|j#EQ#1: selected(i,j))=4;
@sum(OnRoster(i,j)|j#EQ#2: selected(i,j))=6;
@sum(OnRoster(i,j)|j#EQ#3: selected(i,j))=4;
@sum(OnRoster(i,j)|j#EQ#4: selected(i,j))=4;
@sum(OnRoster(i,j)|j#EQ#5: selected(i,j))=2;
@for(OnRoster(i,j): @bin(selected));
end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Civil Engineering Questions!