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

Missing Constraint #4

Open
bwatkin79 opened this issue Jul 25, 2018 · 4 comments
Open

Missing Constraint #4

bwatkin79 opened this issue Jul 25, 2018 · 4 comments

Comments

@bwatkin79
Copy link

line 30 #only keep 4th order and earlier batters, cuz they make more points
On line 30 of the baseball_formulations program, you mention the batting order constraint, but I did not see the actual constraint in any of the programs. If the constraint is there, please tell me where. I'd like to adjust it. Otherwise, can you please provide the constraint that is missing?

@jnederlo
Copy link

jnederlo commented Jul 25, 2018

It's not in there, if you want it you'll have to add it yourself. But from my understanding of it, it won't be feasible in most cases.

@bwatkin79
Copy link
Author

I have made several attempts to create the constraint, but I'm still new to programming and only found out about Julia when I discovered the MIT project these programs were built for. It seems the way objects are created is a lot different than Python or something. This is what I have so far:
#HITTERS in batting order based on slots 1-5 constraint @addConstraint(m, order[b=1:num_players],1 <= players[b:Batting_Order_Confirmed_]) @addConstraint(m, order[b=1:num_players], players[b:Batting_Order_Confirmed_] <= 5)

Another attempt:
#HITTERS in batting order slots 1-5 constraint @addConstraint(m, 1 <= players[i,:Batting_Order_Confirmed_], i=1:num_players}) @addConstraint(m, players[i,:Batting_Order_Confirmed_], i=1:num_players} <= 5)

I'm not sure if I'm even close to getting it right. I think the constraint needs to use :Batting_Order_Confirmed_ but it gave me an error saying it was undefined at one point. On the second example, it says "i" is undefined. I've been adding this into the baseball_formulations.jl file with the other constraints. Can someone please help?

@bwatkin79
Copy link
Author

jnederlo - Would making these changes accomplish what I'm trying to do? Assume we use the 1-6 batters. I'm new to Julia, but it seems like this would work if the way I'm reading the program is right. Definitely possible I'm not though.

In baseball_formulations.jl -
line 52 #number of stacks per team (this is 9)
line 53 num_stacks = 6;

In data_cleaning.jl -
line 402 #STACK players_stacks stores information on which team each player is on
line 403 num_stacks = 6; #number of stacks

line 409 for j=1:num_stacks
line 410 if players[1,:Batting_Order_Confirmed_] == j
line 411 stack_ind = circshift(collect(1:6),stack_order-j)[1:stack_order[1]]; #index of the stacks

line 425 for j=1:num_stacks
line 426 if players[i,:Batting_Order_Confirmed_] == j
line 427 stack_ind = circshift(collect(1:6),num_stacks-j)[1:num_stacks]; #index of the stacks

I made these changes and the program ran without any errors. What do you think?

@jnederlo
Copy link

I'm not sure, I'm not very familiar with circshift, it's possible what you've done worked, I would manually check with your outputs. But as I mention above, the much simpler way to me seems to just filter your inputs altogether, i.e. filter the data before you send it into julia.

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

2 participants