dfs-with-r / coach

Lineup optimization for daily fantasy sports
https://dfs-with-r.github.io/coach/
GNU General Public License v3.0
46 stars 14 forks source link

Error: You used the variable 'x' with at least one index that does not exists. #23

Closed meteoman2210 closed 2 years ago

meteoman2210 commented 4 years ago

Hi,

I'm really looking forward to using your program. However, I can't get started. I keep getting this "Error: You used the variable 'x' with at least one index that does not exists."

Below is the code I am using along with traceback on the error.

I did some searching for the error and found this: https://github.com/dirkschumacher/ompr/issues/281

Embedded within the discussion is perhaps a solution - "You should download the last version of ompr from github."

Might that be the problem here?

Thank you.

Ray O'Keefe

`model <- add_generic_positions_constraint(model, xyz, constraints) results <- optimize_generic(xyz, model, L = 2) Error: You used the variable 'x' with at least one index that does not exists.

traceback() 12: stop("You used the variable '", var_name, "' with at least one index that does not exists.", call. = FALSE) 11: x[i] 10: x[i] 9: rlang::eval_tidy(ast, data = subscript_combinations) 8: sum_expr(x[i], i = roster) 7: rlang::eval_tidy(lhs_ast, env = var_envir, data = data) 6: eval_constraint(lhs_ast, rhs_ast, sense) 5: addconstraint.milp_model(.model, lazyeval::as.lazy(substitute(.constraint_expr), parent.frame()), .dots = lazyeval::lazy_dots(...), .show_progress_bar = .show_progress_bar) 4: addconstraint(.model, lazyeval::as.lazy(substitute(.constraint_expr), parent.frame()), .dots = lazyeval::lazy_dots(...), .show_progress_bar = .show_progress_bar) 3: add_constraint(model, sum_expr(x[i], i = roster) <= m) 2: add_existing_roster_constraint(model, roster_rowids) 1: optimize_generic(xyz, model, L = 2) 1: optimize_generic(xyz, model, L = 2)`

MrMelly-arch commented 3 years ago

@meteoman2210 hey there - ran into same issues as you. Have you had any luck working this out?

I have my projections and salary aligned, but continuously run into the "Error: You used the variable 'x' with at least one index that does not exists." warning when trying to run:

optimize_generic(data, model, L = 3)

zamorarr commented 3 years ago

hi thanks for the bug report. I'll look into this today!

zamorarr commented 3 years ago

Do either of you have an example code and/or csv file I could start with to reproduce the problem? I'm not getting any issues here. For what its worth, there are two issues that commonly occur:

And if its neither of those things send me an example I'll be happy to dig in.