Questions tagged [linear-programming]
An optimization technique for minimizing or maximizing a function of several variables in the presence of constraints where all relationships are linear.
2,368
questions
0
votes
1
answer
46
views
What is the most typographically safe way to write a linear program in R?
In R, linear programming using the lpsolve library requires an extensive amount of manually typed values for the needed matrices and vectors for the objective function coefficients, left-hand side ...
0
votes
0
answers
12
views
How can I use min-cut to seperate a weighted directed graph into 2 subsets of a given size?
I have created a weighted directed graph of 21 nodes. I have to seperate this graph into two subgraphs of approximately equal size. I need either a 10/11 node division, or a 9/12 node division.
My ...
0
votes
1
answer
37
views
formulate max and min in the same linear programing in matlab
I am programing a "customer satisfaction" model which I should use max and min in one linear programing. How can I do that? I have this Idea to use max term as a "subtraction" so ...
0
votes
0
answers
22
views
How to resolve ladder constraints with pulp
We now have a scenario where the cost of sending SMS channels is optimal. There are hundreds of channels, which support different types of SMS messages, different suppliers, and multiple operators. In ...
0
votes
1
answer
60
views
scipy.optimize.minimize SLSQP indirect constraints problem
I am struggling with minimize (method=SLSQL) and need help. This is a simplified car battery (dis)charging problem to prop up the power grid during reduced stability (peak demand). What I expect to ...
0
votes
1
answer
46
views
Pyomo constraints and model execution issues when modeling from mySQL database
I have written a pyomo code in python to help me with a linear programming problem. I posted about it earlier, but my question was understandably too broad. I've worked on the code and hope that I can ...
0
votes
1
answer
95
views
largest and others constraints in portfolio optimization (MILP problem) CVXPY
Here is python code in cvxpy:
import numpy as np
import time
import cvxpy as cp
n = 10
a = np.random.randint(1, 10, size=n)
b = np.random.randint(1, 10, size=n)
c = np.random.randint(1, 10, size=n)
...
0
votes
1
answer
27
views
Pulp - LP Objective function formulation
I am working on solving a set covering problem for electric vehicle charging stations. My objective is to maximize the demand covered by the radius of a charging station.
I have two variables to make ...
1
vote
2
answers
146
views
How to allocate a product using R
I want to solve the following problem using R, and I am struggling to find a good way to do so.
I have a sales forecasts for two products (Product 1 & Product 2), of which there are 2 variations ...
0
votes
1
answer
55
views
Constraints with condition in CVXPY
I want to add constraints like this:
constraint = cp.sum(cp.multiply(x, a)) > 10 if x*a != 0
where x is decision variable and a is constant. I know if condition and chain constraints are not ...
0
votes
1
answer
29
views
Excel Solver MOLP - is there a way to Maximise Amount whilst Minimising cost?
Is there a way to use solver in a way to maximise X wilst using as little of budget Y as possible?
Looked onlime but can't find any MOLP videos using excel, mainly just mathematical literature.
this ...
0
votes
1
answer
30
views
PuLP linear programming problem is infeasible
I am writing a Linear Programming problem to help generate daily fantasy lineups.
The goal is:
Maximize Fpts projection
The constraints are:
Salary (Maximum 50,000)
Positionality (Have to have 1 PG,...
0
votes
1
answer
52
views
LP Programming with python using Pulp library
I have a linear programming problem where I need to minimise the cost of manufacturing a number of items in the span of n months. Xi is the variable for each amount of items manufactured corresponding ...
0
votes
0
answers
22
views
MILP - Adding a constraint renders solution feasible?
I am using CBC solver in Pulp.
I have an MILP where I know a feasible solution exists.
Yet, I received a "Solution is not feasible" error.
I added a constraint "var_1 == var_2", ...
1
vote
1
answer
30
views
ILP - "Is variable equal to another variable"
In an ILP, given two variables x and y, is it possible to define a variable z where
z = (x==y)?
Meaning, if x equals y then z = 1.
Else, z = 0.
x and y are integer variables bounded between (1, M).
0
votes
0
answers
28
views
Transport Optimization (PuLP) with Shipping Volume Discount
In the transport optimization problem of PuLP, i am want to optimize the final cost after taking into consideration volume based cost discount. Hence in the problem below we have 3 warehouses and 3 ...
0
votes
1
answer
41
views
Ilp - count number of times variables received a value
In an ILP, is it possible to have a variable whose value will be the number of variables with value N?
N is a bounded integer, with lower bound 1.
Thank you
1
vote
0
answers
24
views
JS lp-solver. How to use all the products at least once?
I made a linear program code for a diet app that minimizes the cost of products while meeting user's desired calories. It is working, at least somewhat working. The problem is that the result is made ...
0
votes
0
answers
14
views
Defining variables for JS lp-solver using an array
I'm trying to create a linear programing code in JS using lp-solver library, but I can't get the results to be outputted. It's probably because of incorrect model, because the results output for each ...
0
votes
2
answers
703
views
Unexpected token 'o', "[object Obj"... is not a valid JSON
I have written a function in PHP which takes product information and user's desired calories information from a database and puts all of the information in an array. Afterwards it's encoded in JSON. ...
0
votes
1
answer
36
views
Error Type Not an array type in constrain defined in Cplex
I wrote an simple Binpacking problem in Cplex from here. My code is:
//Parameters
using CP;
int n=...;//Num item
range Item = 1..n;
range Bin = 1..n;
float c=...; //Volume Bin
float w_j=...; //...
-1
votes
1
answer
41
views
ILP: Exclusive range for variable
In an ILP, How can I write a constraint "X is not in the interval [Y, Y+10]" ?
Is it even possible?
0
votes
0
answers
15
views
linearize if then implication with system of inequations in the condition
While working on some linear program I had the following problem:
t is time index
s is a time decision variable
p is a time decision variable
q is a Boolean decision variable
x[t] is a Boolean ...
0
votes
0
answers
28
views
Check constraint noninfringement in PuLP
I have just created a model in PuLP, though its result seems to have violated its constraints. Is there a quick way to check the value of each constraint?
1
vote
2
answers
217
views
How to use CP-SAT solver or other tools to find 3D arrays with constraints on rows, columns and tubes (representing school classes, terms and days)?
I will be grateful to anyone who can help me write some Python code to enumerate the 21×2×3 arrays, indexed with i, j and k, which are two-thirds filled with 0's and one-third filled with the values '...
1
vote
2
answers
55
views
Creating Integer Range from multiple string math expressions in python
I have a problem in a project and I've searched the internet high and low with no clear answer.
How can i convert math expressions
As 3x + 5y >= 100
And x,y < 500
Into a range of x and range of ...
1
vote
1
answer
72
views
Linear programming algorithm and equally share with Python PuLP
I have a variable named total_fuel_available which contains total amount of fuel available.
I have a list of zone object and each zone object contains 2 attributes :
the first is local_fuel_limit ...
2
votes
1
answer
67
views
Creating an automatic tennis team selection program in Python, given match rules and a ranking, using logic toolkit
I’m trying to apply programming to a real-life problem that comes around each year for my tennis team. It’s about picking the best team for a team match, given some rules. I thought I’d have a go at ...
2
votes
3
answers
179
views
Algorithm to arrange audio tracks on a number of sides of vinyl, optimizing for smallest maximum side length?
We have a number of audio tracks, and a number of groups called “sides” (each corresponding to one side of a vinyl record). For each track, we know its name and its length in seconds. Each side also ...
0
votes
1
answer
28
views
Cannot get total of required 100 in Scipy linear programming
I am trying to solve a optimization problem, When I use too simple data sets, I get accurate results and the sum of res.x sums up to 100, which I want, but when I use my original data, the res.x ...
0
votes
1
answer
53
views
linear programing: find max number of shares of stock to purchase given a budget
The problem I am working on is this: say i have 10k, and I want to buy 3 stocks: AMZN, CBOE, CDW. and my goal is the calculate the max number of shares I can purchase and stay within 10k.
X*amzn_price+...
0
votes
1
answer
39
views
IBM CPLEX C++ concert technology - Infeasible solution
I am using the ILP approach for one of my research problems. Initially formulated the ILP using mathematical programming (.mod), it works fine. But while compiling the c++ code of the formulated ILP ...
1
vote
1
answer
52
views
Get If (condition), then (assign value), else (assign other value) statement in Linear Programming
I'm looking for a linear programming equation that satisfied the conditions;
Given that all variables here are binary variables
if A+B = 2; then C = 1; else C = 0
Also,
if A+B+D = 3; then E = 1; else ...
0
votes
0
answers
19
views
How to reduce an optimization model's bias without changing the weights assigned to a feature?
Given a linear model, say revenue as the dependent variable and f1, f2, ... fn as the independent variables, each with different weights assigned. Can you reduce the model's sensitivity or bias ...
0
votes
1
answer
24
views
PuLP, groupby columns to see if sum for group is larger than group's threshold
import numpy as np
import pandas as pd
d = {'id':['6G','4F','2W','1H','7P','3L'],
'contract': ['contract_1', 'contract_1', 'contract_1', 'contract_2', 'contract_2', 'contract_3'],
'...
0
votes
1
answer
31
views
How to correctly define a quadratic constraint on xpress
I'm implementing on Xpress a problem with different solution proposed on a paper. The idea is to decompose a matrix X into a convex sum of 0 1 matrices.
Among the constraints of the problem, the ...
1
vote
1
answer
36
views
OR Constraints in PuLP
I'm trying to add an or constraint in PuLP to choose between two cases. In short, I have a set of binary variables that I want all to be 1 or 0 at once. I'm trying to solve a scheduling problem and I ...
1
vote
0
answers
49
views
Expressing constraints in scipy's linprog
Let's say we have a cloud of n points, m dimensional: x1(x1m1, x1m2...), x2, x3...
Now let's add an aditional point p(pm1, pm2...)
Point P needs to fulfill these 3 conditions:
P = a1x1 + a2x2 + a3*x3 ...
0
votes
0
answers
34
views
Optimization based on rank and absolute deviation
I have a problem statement where i am trying to optimize the position of the shipment such that 2 specific objectives are met, Deviation time and inherent ranking
Given: some Shipments, the objective ...
1
vote
1
answer
72
views
How to use XPRESS as solver in Google OR Tools?
Google OR Tools says that it supports FICO XPRESS. Using Python, calling help(pywraplp.Solver.CreateSolver) I see that it supports
- XPRESS_LINEAR_PROGRAMMING or XPRESS_LP
- ...
0
votes
2
answers
91
views
Linear programming with PuLP - Output of variables are none
I'm trying to write a model for a nitrogen production facility to minimize the electricity costs. The facility can produce nitrogen and inject or extract it from the storage. The injection requires ...
0
votes
1
answer
170
views
Given an array of numbers (integer or float) and an integer M, output M number of subsets such that the subset with the highest sum is minimised
Dear stackoverflow community,
Currently, I am attempting to solve an optimisation problem whereby given an array of numbers (integer or float; non-negative) and a positive integer M, output M number ...
0
votes
0
answers
34
views
Unable to solve a LP Problem in python using docplex
from docplex.mp.model import Model
m = Model(name="LP_Problem")
x1 = m.continuous_var(name="x1")
x2 = m.continuous_var(name="x2")
c11 = m.add_constraint( x1 + x2 <= ...
1
vote
1
answer
36
views
I'm trying to use the boolean variable in my optimization problem. It displays "IndexError: list index out of range"
What is wrong with my code or approach?
My optimization model's objective is to select the companies that are profitable given their cost and the profit they can make. Namely, the companies are A,B ...
0
votes
1
answer
45
views
How to create a CVXPY Variable with discontinuous range?
I am trying to optimize a inventory control linear program for month to month over a year. I cannot figure out how to program a variable that can either be 0 or greater than 50. I have three ...
0
votes
2
answers
45
views
What is the correct way to import data from a link?
I'm working with the xpress library due to a project I'm developing. As I have to use some official data, here is how I'm trying to retrive it:
import xpress as xp
import numpy as np
import pandas as ...
0
votes
0
answers
55
views
How to set the floating point precision in Scipy?
I am using Scipy to solve the following linear programming problem. However, I have to set the precision for the decision variable r to a maximum of double-precision floating-point numbers. Can ...
1
vote
1
answer
57
views
Linear Programming, max function (if statement)
I have a value x, which is a combination of decision variables.
I need to calculate a cost, which only triggers if x > 100. So cost = MAX(x - 100, 0) * 20.
Is there any way to do this in linear ...
0
votes
1
answer
58
views
Weird performance of my code of 4*4 Kakuro Puzzle
I was trying to write the code of performing 4*4 Kakuro puzzles using concept of optimzation. Basically it requires the sum of empty cells in each row and column equal to the first entry of that row ...
0
votes
1
answer
43
views
How to solve this warning "Decision variable "IL#0#0#0#0#0#0" has never been used by the engine."?
I have been working on the mathematical model for a long time and now I could improve it. In this model we have nodes and edges and the flows that pass through these nodes according to the topology. ...