linear-programming

Code a linear programming exercise by hand

落爺英雄遲暮 提交于 2019-12-03 08:09:21
I have been doing linear programming problems in my class by graphing them but I would like to know how to write a program for a particular problem to solve it for me. If there are too many variables or constraints I could never do this by graphing. Example problem, maximize 5x + 3y with constraints: 5x - 2y >= 0 x + y <= 7 x <= 5 x >= 0 y >= 0 I graphed this and got a visible region with 3 corners. x=5 y=2 is the optimal point. How do I turn this into code? I know of the simplex method. And very importantly, will all LP problems be coded in the same structure? Would brute force work? There

Any good tools to solve integer programs on linux? [closed]

99封情书 提交于 2019-12-03 07:34:19
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Are there any good tools to solve integer programs on Linux? I have a small problem that I want to compute to save time :D. It is kind of a subset sum problem. I have a list of around 20 Integer-Values and I want to compute the subset with the smallest sum that satisfies a certain minimum. You could formulate this with a integer program... something like \sum_{i=1}^{n} w*x -> min with \sum_{i=1}^{n} w*x >= c with x \in \

Linear programming library for .NET / C# [closed]

☆樱花仙子☆ 提交于 2019-12-03 06:50:50
I need to solve an under-determined linear system of equations and constraints, then find the particular solution that minimises a cost function. This needs to be done in purely portable managed code that will run in .NET and Mono. What freely available libraries are there that I can use to implement this? All of the optimisation algorithms provided by free libraries I have found only support interval constraints on single variables, e.g. 0 < x < 1 , not constraints like x + 2y < 4 . I have also found that often the linear equations solvers only support linear systems with one solution. The

What is the benefit of using exponential backoff?

拈花ヽ惹草 提交于 2019-12-03 06:12:46
When the code is waiting for some condition in which delay time is not deterministic, it looks like many people choose to use exponential backoff, i.e. wait N seconds, check if the condition satisfies; if not, wait for 2N seconds, check the condition, etc. What is the benefit of this over checking in a constant/linearly increasing time span? This is the behavior of TCP congestion control. If the network is extremely congested, effectively no traffic gets through. If every node waits for a constant time before checking, the traffic just for checking will continue to clog the network, and the

Port MATLAB bounding ellipsoid code to Python

China☆狼群 提交于 2019-12-03 03:19:14
MATLAB code exists to find the so-called "minimum volume enclosing ellipsoid" (e.g. here , also here ). I'll paste the relevant part for convenience: function [A , c] = MinVolEllipse(P, tolerance) [d N] = size(P); Q = zeros(d+1,N); Q(1:d,:) = P(1:d,1:N); Q(d+1,:) = ones(1,N); count = 1; err = 1; u = (1/N) * ones(N,1); while err > tolerance, X = Q * diag(u) * Q'; M = diag(Q' * inv(X) * Q); [maximum j] = max(M); step_size = (maximum - d -1)/((d+1)*(maximum-1)); new_u = (1 - step_size)*u ; new_u(j) = new_u(j) + step_size; count = count + 1; err = norm(new_u - u); u = new_u; end U = diag(u); A =

How can I do functions in CPLEX?

左心房为你撑大大i 提交于 2019-12-02 20:19:16
问题 I am trying to find small-working-example about CPLEX with functions. Bad example here how not do things. How are functions defined in CPLEX? P.s. I am doing already submitted work for the linear-optimization -course 2.3140 here, in Aalto University. 回答1: You write it like a mathematical problem, you had an error with index-out-of-bound. // Decision variables dvar float+ z[0..4]; dvar float a[0..4]; dvar float+ x[0..5]; dvar float+ v[0..5]; minimize sum(myZ in 0..4) z[myZ]; subject to {

How can I do functions in CPLEX?

泪湿孤枕 提交于 2019-12-02 08:11:48
I am trying to find small-working-example about CPLEX with functions. Bad example here how not do things. How are functions defined in CPLEX? P.s. I am doing already submitted work for the linear-optimization -course 2.3140 here , in Aalto University. hhh You write it like a mathematical problem, you had an error with index-out-of-bound. // Decision variables dvar float+ z[0..4]; dvar float a[0..4]; dvar float+ x[0..5]; dvar float+ v[0..5]; minimize sum(myZ in 0..4) z[myZ]; subject to { startX: x[0]==0; startV: v[0]==0; endX: x[4]==1; x[5]==1; endV: v[4]==0; v[5]==0; forall(t in 0..4){ a[t]<=z

How to solve a linear programing in matlab in canonical representation? [closed]

冷暖自知 提交于 2019-12-02 06:14:20
Is it possible to enter matlab a string like that: MAX 140 x1 + 160 x2 +x3 SUBJECT TO 2 x1 + 4 x2 <= 28 5x1 + 5.333x2 -500X3 = 0 x1 <= 8 x2 <= 6 END The toolbox I have installed: v = ver; setdiff({v.Name}, 'MATLAB')' ans = 'Aerospace Blockset' 'Aerospace Toolbox' 'Bioinformatics Toolbox' 'Communications System Toolbox' 'Computer Vision System Toolbox' 'Control System Toolbox' 'Curve Fitting Toolbox' 'DSP System Toolbox' 'Database Toolbox' 'Datafeed Toolbox' 'Econometrics Toolbox' 'Embedded Coder' 'Filter Design HDL Coder' 'Financial Derivatives Toolbox' 'Financial Toolbox' 'Fixed-Income

gurobi - Error code = 10004 Unable to retrieve attribute 'X'

不想你离开。 提交于 2019-12-01 06:04:22
I am getting an error in my c++/gurobi file: Error code = 10004 Unable to retrieve attribute 'X' I read that this might have something to do with labels? But I don't see how there is a problem. It works for some input files, but not for others. So I have created a toy file, t5.txt in attachment. This file does not work, but removing the last column and setting 8 to 7 fixes it. I am puzzled... Below is the output of model.write. Everything seems to make sense, any Ideas what I am doing wrong? Whenever I do a model.write(test.sol), the program stops, so there seems to be something wrong with the

Shortest distance from a point to this curve

孤者浪人 提交于 2019-12-01 05:12:18
I need to find the distance of multiple points to a curve of the form: f(x) = a^(k^(bx)) My first option was using its derivative, using a line of the form with the inverse of the derivative, giving it coordinates of the Point and intersecting it with the original curve. Finally, we calculate the distance between points with simple geometry. That's the mathematical process that I usually follow. I need to save time (since I'm doing a genetic algorithms program) so I need an efficient way to do this. Ideas? The distance between a point (c,d) and your curve is the minimum of the function sqrt((c