Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimension Mismatch #5

Open
Croftc opened this issue Mar 14, 2018 · 14 comments
Open

Dimension Mismatch #5

Croftc opened this issue Mar 14, 2018 · 14 comments

Comments

@Croftc
Copy link

Croftc commented Mar 14, 2018

I am successfully able to run all provided formulations on the provided test data, but running on actual data, formulations 3 and 4 don't work - specifically the defensemen stacking constraint. The error I receive states:

glp_intopt: optimal basis to initial LP relaxation not provided
WARNING: Not solved to optimality, status: Infeasible
WARNING: Infeasibility ray (Farkas proof) not available
ERROR: LoadError: DimensionMismatch("mismatch in dimension 1 (expected 1 got 217)")

@jcameronmetz
Copy link

Did you ever get this working I'm having the same issue? The (Array{Int64,0})[] was a big fix

@jcameronmetz
Copy link

This was also given : DimensionMismatch("mismatch in dimension 1 (expected 1 got 360)")

@trbradle44
Copy link

trbradle44 commented Oct 19, 2018 via email

@shane-rand
Copy link

Any luck on this? I'm running into the same error and I verified teams and opponents matching up.

@jcameronmetz
Copy link

jcameronmetz commented Dec 14, 2018 via email

@shane-rand
Copy link

@jcameronmetz Can you let me know how you fixed this?

@jcameronmetz
Copy link

@constraint needs to be changed

@variable needs changed

Those are the things that helped work for me.

@jcameronmetz
Copy link

Variable for skaters in lineup.

@defVar(m, skaters_lineup[i=1:num_skaters], Bin)   -> change this to @variable

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


# One goalie constraint
@addConstraint(m, sum{goalies_lineup[i], i=1:num_goalies} == 1)  change this to @constraint

@shane-rand
Copy link

@jcameronmetz Hmm, unfortunately I already had those fixes in my code. Still experiencing the issue. I believe since the model is not being solved, its throwing the error on the next lineup creation.

The example data works perfectly, leading me to believe I've set up my data wrong? If you could send over your last data file that worked (both skaters.csv and goalies.csv) that would be appreciated.

@shane-rand
Copy link

Still working on this....

I've found that its the 'at least one full line' and 'defenseman on powerplay one' constraints that are the problem. Currently trying to decipher those constraints...

@jcameronmetz
Copy link

jcameronmetz commented Dec 18, 2018 via email

@shane-rand
Copy link

Finally figured it out.

for num=1:size(skaters)[1]
if skaters[:Team][num] == teams[1]
if skaters[:Line][num] == "1"
L1_info[num] = 1
elseif skaters[:Line][num] == "2"
L2_info[num] = 1
elseif skaters[:Line][num] == "3"
L3_info[num] = 1
elseif skaters[:Line][num] == "4"
L4_info[num] = 1
end
end
end
team_lines = hcat(L1_info, L2_info, L3_info, L4_info)
for num2 = 2:size(teams)[1]
L1_info = zeros(Int, num_skaters)
L2_info = zeros(Int, num_skaters)
L3_info = zeros(Int, num_skaters)
L4_info = zeros(Int, num_skaters)
for num=1:size(skaters)[1]
if skaters[:Team][num] == teams[num2]
if skaters[:Line][num] == "1"
L1_info[num] = 1
elseif skaters[:Line][num] == "2"
L2_info[num] = 1
elseif skaters[:Line][num] == "3"
L3_info[num] = 1
elseif skaters[:Line][num] == "4"
L4_info[num] = 1
end
end
end
team_lines = hcat(team_lines, L1_info, L2_info, L3_info, L4_info)
end
num_lines = size(team_lines)[2]
# Create power play indicators
PP_info = zeros(Int, num_skaters)
for num=1:size(skaters)[1]
if skaters[:Team][num]==teams[1]
if skaters[:Power_Play][num] == "1"
PP_info[num] = 1
end
end
end
P1_info = PP_info
for num2=2:size(teams)[1]
PP_info = zeros(Int, num_skaters)
for num=1:size(skaters)[1]
if skaters[:Team][num] == teams[num2]
if skaters[:Power_Play][num] == "1"
PP_info[num]=1
end
end
end
P1_info = hcat(P1_info, PP_info)
end

These lines are using double quotes around the line numbers for comparison. I removed the quotes and compared as a number and everything worked swimmingly.

@awiden91
Copy link

awiden91 commented Jan 3, 2020

@shane-rand Hey, could you please send over the full code that you used to get it running? I am having trouble updating it and keep running into a LoadError: UndefVarError: i not defined error. Would you be able to help me with this. Thank you and I appreciate your time!

@mhbw
Copy link

mhbw commented Sep 21, 2022

@awiden91 also hitting the "I not defined" issue; did you ever solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants