You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to add a new constraint to my optimization model. I work with omprt library. I have stores (j) and customers (i). I want to minimize transportation cost.
My model is same with your example:
MIPModel() %>%
add_variable(x[i, j], i = 1:n, j = 1:m, type = "binary") %>%
I want to add a new constraint. For example I have 30 different stores. First 10 stores have to sell minimum 15 units, second 20 stores have to sell minimum 10 units and third 30 stores have to sell 5 units.
I try to write like this but it didn't work:
add_constraint(sum_expr(y[j], j=1:30) >= 30, i = 1:n)
This discussion was converted from issue #319 on January 07, 2022 08:44.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I want to add a new constraint to my optimization model. I work with omprt library. I have stores (j) and customers (i). I want to minimize transportation cost.
My model is same with your example:
MIPModel() %>%
add_variable(x[i, j], i = 1:n, j = 1:m, type = "binary") %>%
add_variable(y[j], j = 1:m, type = "binary") %>%
set_objective(sum_expr(transportcost(i, j) * x[i, j], i = 1:n, j = 1:m) + sum_expr(fixedcost[j] * y[j], j = 1:m), "min") %>%
add_constraint(sum_expr(x[i, j], j = 1:m) == 1, i = 1:n) %>%
add_constraint(x[i,j] <= y[j], i = 1:n, j = 1:m)
I want to add a new constraint. For example I have 30 different stores. First 10 stores have to sell minimum 15 units, second 20 stores have to sell minimum 10 units and third 30 stores have to sell 5 units.
I try to write like this but it didn't work:
add_constraint(sum_expr(y[j], j=1:30) >= 30, i = 1:n)
Please help!!!
Beta Was this translation helpful? Give feedback.
All reactions