indexing within constraints - I am looking for help :) #364
Unanswered
chris13337
asked this question in
Q&A
Replies: 1 comment
-
👋 Please provide a reproducible example (https://reprex.tidyverse.org/) if possible, then it is easier to find the problem. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am using the OMPR package for a few months now and I, first of all, would like to thank you for the great effort you put into this!
I am having a problem while formulating a problem. This is a working code example from me:
` add_constraint(sum_expr(x[i]* help_matrix[i,1],i = 1:length(projection$proj_total)) <= 3) %>%
add_constraint(sum_expr(x[i]* help_matrix[i,2],i = 1:length(projection$proj_total)) <= 3) %>%
add_constraint(sum_expr(x[i]* help_matrix[i,3],i = 1:length(projection$proj_total)) <= 3) %>%
add_constraint(sum_expr(x[i]* help_matrix[i,4],i = 1:length(projection$proj_total)) <= 3) %>%
add_constraint(sum_expr(x[i]* help_matrix[i,5],i = 1:length(projection$proj_total)) <= 3) %>% `
is there a more efficient way to do it? ( I am sure there is one, but I am not able to implement it. I tried this:
add_constraint(sum_expr(x[i]* help_matrix[i,j],i = 1:length(projection$proj_total)) <= 3,j <- 1:5) %>%
but I get an error for this:
Fehler in check_for_unknown_vars_impl(model, the_ast) :
The expression contains a variable that is not part of the model.
how can this be solved?
I am looking forward to your answer!
Kind regards,
Christian Schumacher
Beta Was this translation helpful? Give feedback.
All reactions