简体   繁体   English

使用 python 进行线性规划

[英]linear programming with python

I'am trying to solve a following problem.我正在尝试解决以下问题。

在此处输入图像描述

In fact, this is Least Absolute Deviation Regression problem.实际上,这是最小绝对偏差回归问题。 I want to know how to solve this with python.我想知道如何用 python 解决这个问题。 I know that scipy has "linprog" which solve linear system with linear inequality constraints.我知道 scipy 具有“linprog”,可以解决具有线性不等式约束的线性系统。 But here there is two variable in inequality constraints, t, x.但是这里有两个不等式约束变量,t,x。 So, I want to know how to apply the "linprog" or is there other library which can solve this problem?所以,我想知道如何应用“linprog”或者是否有其他库可以解决这个问题? Thanks谢谢

You have to write your problem in standard form, splitting the second inequality constraint and concatenating the two optimization variables.您必须以标准形式编写问题,拆分第二个不等式约束并连接两个优化变量。 Then, you can feed it to linprog .然后,您可以将其提供给linprog

It is more of a math problem than an implementation one.这更像是一个数学问题,而不是一个实现问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM