Questions tagged [ompr]
25 questions
3
votes
1 answer
In the ompr package in R, how can I rephrase my objective/constraints/variables so as to avoid the "problem too large" error?
I am trying to learn to fit a linear integer programming optimization model in R using the ompr package that a colleague had previously fit using CPLEX/GAMS (specifically, the one described here: Haight et al. 2021). I am running my implementation…

Bajcz
- 433
- 5
- 20
2
votes
4 answers
Is there a way to define a complex objective function in an R optimizer?
In R, I am trying to optimize the following : choose rows which maximize the number of columns whose sum exceeds a certain value which varies by column + some other basic constraints on the row selections.
Is there anything out there in R which…

Benjamin Battle
- 21
- 3
2
votes
3 answers
MIP (ompr) model taking too much time to solve in R
I am trying to solve a capacitated facility location problem in R. The sample data for that:
n<- 500 #number of customers
m<- 20 #number of facility centers
set.seed(1234)
fixedcost <- round(runif(m, min=5000, max=10000))
warehouse_locations <-…

Shibaprasadb
- 1,307
- 1
- 7
- 22
2
votes
0 answers
Optimisation in R: Creating an exam schedule (ompr, ROI ?)
I'm scheduling an exam for a course (using R).
I have 36 students, which all need to be fitted with time-slots to 8 teachers on the exam day (1:1 exams).
Each student or teacher can obviously only be in one place at a time.
How do I run an…

Silviculturalist
- 199
- 11
1
vote
0 answers
ompr.highs package not working on my computer
Since i have changed my computer i have an issue with the ompr.highs package.
I ran this exemple code :
library(ompr)
library(ompr.highs)
suppressPackageStartupMessages(library(dplyr, quietly = TRUE))
max_bins <- 10
bin_size <- 3
n <- 10
weights <-…

Mousta1101
- 11
- 2
1
vote
1 answer
Need help to add a constraint to a MIP model in R
I'm trying to build a model to optimize steel production. The objective is to reduce the amount of waste (leftover material after the steel has been cut). The code below is what I have so far. It is lacking a constraint to make sure that each item…

RegressionSquirrel
- 422
- 3
- 8
1
vote
2 answers
Transportation cost optimisation using OMPR for a large data set
I am solving a transport optimization problem given a set of constraints.
The following are the three key data sets that I have
#demand file
demand - has demand(DEMAND) across 4821(DPP) sale points(D)
head(demand)
D PP…

Srikanth Viswanathan
- 15
- 3
1
vote
0 answers
How to solve "index not found error" in ompr package R?
I'm using ompr package to develop BIN PACKING problem as staed in the following link:
https://developers.google.com/optimization/bin/bin_packing
This is the code I run:
# Import lpSolve package
library(lpSolve)
#Import required…

Diego Fabbri
- 11
- 1
1
vote
0 answers
R OMPR- Adding a new constraint and dimension to matrix
I'm using the OMPR package in r in order to solve some constraint problems with my keeper-league soccer/football team. This league is operated very much like a real Premier League team, where I wanted to maximize the total number of goals…

BigDawgBigBite
- 11
- 1
1
vote
0 answers
How to define 3D variable in OMPR package of R?
I am trying to solve a MILP supply network optimization problem using R's OMPR package. I need to define a 3D binary variable (x[i,j,q]) in the model to map Customers (i) to DC (j) by each SKU (q). Does anyone know how I can do that?
With my current…

Samidha
- 11
- 2
1
vote
1 answer
ompr MILPModel : non-numeric argument to binary operator
I am familiar with how to use ompr::MIPModel but am trying to learn how to use MILPModel to take advantage of the model build speed. A simplified version of my model is below. I have two decision variables, x and y, binary and of equal length. I…

Ralph Asher
- 192
- 9
1
vote
1 answer
R: ompr package constraints
I am using ompr package in R to solve an omptimization problem.
The optimization problem in written looks like this:
Min wi * xi
xi ϵ {0,1}
xi ≤ xj , j follower of i
i is a follower of j if in the distance matrix (distmatrix) a value is available.…

Mara
- 13
- 3
0
votes
1 answer
optimize function to maximimize value given a list of unique numbers
I have a function that calculates the total value given a vector of unique integer numbers. For example, in the problem below i would like to find the maximum value by changing the vector numbers.
Constraints are that the vector must be a length of…

jsimpsno
- 448
- 4
- 19
0
votes
1 answer
Optimization - big M approach ompr
I'm trying to implement the big M approach to a simple problem but I'm struggling a lot as I'm new on optimization tasks.
I'm using the ompr package to solve the folowing problem:
Trying to minimise the sum of puchase cost defined as: sum("needed"…

jimprideaux
- 13
- 3
0
votes
1 answer
How to force minimum number of groups in linear programming problem using ompr
The following problem seeks to maximize the weight across any 3 items while being under a cost of 20. I gave group "a" a large weight so that the model will only select the 3 items from group "a". How do I force the model to include at least 2…

Giovanni Colitti
- 1,982
- 11
- 24