Skip to main content
8 votes

Reducing number of suppliers for product portfolio

You can model this as a set covering problem (or hitting set problem -- different terminology, same mathematical model). The (binary) decision variables would determine which suppliers you select; the ...
prubin's user avatar
  • 39.3k
8 votes

When should I use a solver for IP and MIP and can I just use a library from Python, R, Matlab, etc...?

I assume the solver you're referring to in Python/R/Matlab, are the open-source solvers such as CBC or GLPK (you can find out more in this question: Where can I find open source LP solvers?). If that'...
EhsanK's user avatar
  • 5,864
7 votes

Using R for coding Matheuristic for Research Publication

You mention data pre-/post-processing. If what you propose to do is in the context of data science (for instance, a matheuristic for outlier identification to be embedded in some statistical data-...
prubin's user avatar
  • 39.3k
7 votes

Queuing models in R, $\lambda$ Little

Not directly answering your question of how to code it manually but for discrete simulation of queues in R I would strongly recommend the simmer package. The ...
CMichael's user avatar
  • 1,333
6 votes

VRP package for R

The package netgen (v1.3) can be used to generate networks and benchmark instances of VRP and TSP. As this article shows it is also possible to solve a variant of ...
TheSimpliFire's user avatar
  • 5,412
5 votes
Accepted

Solving Capacitated VRP with multiple various sized vehicles

You could cluster 40,000 dropping locations (by grouping them based on location/vehicle type need) to some reasonable number and can try to implement metaheuristics like Simulated annealing, Particle ...
anjikum's user avatar
  • 984
5 votes
Accepted

Is it possible to merge two objective functions using the LpSolve package in R?

There are a variety of ways to deal with multiple objectives, so the answer is "it depends". Probably the most common approach is to optimize a weighted sum or difference of the individual ...
prubin's user avatar
  • 39.3k
5 votes

Optimization gives me negative value

The ompr::add_variable function has a default value of -Inf for the lower bound (lb) ...
prubin's user avatar
  • 39.3k
4 votes

3D Knapsack Problem: R or Python Packages?

As the container loading problem is NP-hard in its essence, therefore, using a mixed-integer program might not be efficient to solve this kind of problem, except using advanced techniques like column ...
A.Omidi's user avatar
  • 8,950
4 votes

Linear Programming problem for finding supplier

The problem you mentioned sounds like a variant of the lot-sizing problem in which there are multiple sources to produce one of the materials. Let's say, the variable $x_{i,s,t}$ represents the amount ...
A.Omidi's user avatar
  • 8,950
4 votes
Accepted

Optimizing a capacitated clustering problem with Greedy search algorithm

Your distance constraint for each cluster limits the sum of the distance from each cluster point to its nearest neighbor (excluding the last point selected for the cluster, whose nearest neighbor is ...
prubin's user avatar
  • 39.3k
4 votes

Solving Capacitated VRP with multiple various sized vehicles

I'm not an expert in Vehicle Routing Problems, maybe someone else will have something more relevant to propose. I think that a good starting point is this article: "Efficiently solving very large-...
fontanf's user avatar
  • 2,623
4 votes

VRP package for R

I guess it is a bit late now, but recently I have been developing a package for solving large instances of the capacitated multiple-depot vehicle routing problem with mileage constraints, which is ...
Viktor Plamenov's user avatar
4 votes

When should I use a solver for IP and MIP and can I just use a library from Python, R, Matlab, etc...?

The main reasons are performance and quality of numerics. Non-professional stuff tend to lack the polish professionals spend time doing to ensure that numerical issues don't compromise the solving ...
Nikos Kazazakis's user avatar
4 votes

Adjust result to equal mode values

You are looking for a transversal or system of distinct representatives. One approach is to construct a bipartite graph with a left node for each alternative $i$, a right node for each mode $j$, and ...
RobPratt's user avatar
  • 32.3k
4 votes
Accepted

Assign jobs to least people with multiple job constraints

Let $I$ be the set of available persons (you can set this value to an upper bound, e.g. 6 in your case),and $J$ be the set of jobs. $S$ is the set of shifts. $R_j$ is the amount of hours a job needs ...
PeterD's user avatar
  • 1,636
3 votes

Reducing number of suppliers for product portfolio

Let $b_{i,j}$ denote product $i$ is taken from supplier $j$. and $x_j$ denote whether supplier $j$ is selected once or not. $i \in n$ (product) $j \in m$ (supplier) Now: \begin{align}\max&\quad \...
ooo's user avatar
  • 1,589
3 votes
Accepted

DAG shortest path in R - I have a list of nodes, each node's completion time and each node's predecessor(s). How can I turn this to a list of arcs?

The problem here seems to be that the data is provided in a somewhat untidy fashion. To use the function the data needs to be preprocessed to extract each entry from the column "Predecessor(s)". You ...
JakobS's user avatar
  • 2,767
3 votes

Problems with reading CPLEX LP models from file in R by package 'lpSolveAPI'

The first issue is that "LP" format means different things to lpsolve and CPLEX. See the warning about that near the top of the lpsolve page describing their format. There are converters ...
prubin's user avatar
  • 39.3k
3 votes

Solving Capacitated VRP with multiple various sized vehicles

I'm assuming in what follows that all demands must be met. R has a very good genetic algorithm package ("GA") that includes support for permutation chromosomes. Assuming $n$ destinations and ...
prubin's user avatar
  • 39.3k
3 votes
Accepted

How to Use the Weighted Sum Method in R

The GeeksForGeeks page linked in your previous question provides one possible way to scale your attributes. Using that scaling method, your code is correct and two clusters has the highest performance ...
prubin's user avatar
  • 39.3k
3 votes
Accepted

Use the Weighted Sum Method in R

The edited version fixed one problem (numeric fields being character strings). Before using the weightedSum function (or doing any other calculations), you also ...
prubin's user avatar
  • 39.3k
3 votes
Accepted

Using R for coding Matheuristic for Research Publication

A couple of years ago we had a student who wanted to call CPLEX from R and I think after spending a lot of time with a colleague they couldn't get it to work. The situation may have been improved, but ...
Paul Bouman's user avatar
  • 2,100
3 votes
Accepted

Adjust result to equal mode values

There is no guarantee you can avoid ties using mode (or anything else, if it is possible for two alternatives to have identical scores and thus be indistinguishable). Rob's approach (which I endorse) ...
prubin's user avatar
  • 39.3k
3 votes

Include dataframe linear optimization in r

MILP modelling in R is not as advanced or convenient as it is in Python or Julia. Few exceptions I know about are ROI and ompr packages. ompr seems to be actively maintained thanks to Dirk Schumacher. ...
berkorbay's user avatar
  • 341
3 votes
Accepted

Two criteria in a problem that involves multiple-criteria decision-making

More criteria would not necessarily help, and in fact might make it harder to make a selection (for instance, if every alternative excels on some criterion and does badly on some other criterion). ...
prubin's user avatar
  • 39.3k
3 votes

Grouping values based on a difference constraint

Some of this may be solver dependent. I just ran your model with only one change -- switching the solver from glpk to CPLEX -- and got a valid solution (the same as yours, changing group 10 to group 2)...
prubin's user avatar
  • 39.3k
3 votes

Grouping values based on a difference constraint

Since you've a threshold (diff) you may pre-define max of diff number of groups, not the full length of the list. As for the if condition try this $L(x_{i,g}+x_{j,g}-1) \le d - (L_j - L_i)$ where $L$ ...
Sutanu Majumdar's user avatar
3 votes
Accepted

How to Group IDs Based on the Difference of Each ID’s Min and Max Value?

Sounds like shift scheduling, where each id is a shift with start time equal to the min value and end time equal to the max value. Your first condition requires at least a certain amount of rest ...
RobPratt's user avatar
  • 32.3k
2 votes

Linear Programming problem for finding supplier

As @prubin corretly pointed out, the essential problem at hand is the transportation problem with some additional constraints on non-available quantities for relevant material-supplier pairs. I could ...
Patrik's user avatar
  • 183

Only top scored, non community-wiki answers of a minimum length are eligible