Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using python scipy to solve linear programming problems

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Use python scipy to solve linear programming problems, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Recently, an interesting technical point has been encountered in the project, which uses the mathematical model of linear programming to find the optimal solution.

Since my background is springcloud, I have investigated two ways to implement it.

The first is to use python's scipy open source library to write a python script, and then the java background calls the python script to find the optimal solution, and then return the results.

The second is to use the ibm component Cplex in java to solve the problem directly, but it can be divided into fee-based version and free version. The free version is limited to 1000 decision variables, but it is enough. It's hard to find jar bags and dll.

It is found that the optimal solution calculated by the two of them is the same, but the decision variables are not the same.

Here is a record of the method of solving the problem using python.

The inequality equations in the project are in the form of ∑ summation. Here, manual coding first assumes that the number of decision variables is 5 * 3. After simplification, the multivariate primary inequality group is as follows:

Solve the maximum = AX + AY + AZ + BX + BY + BZ + CX + CY + CZ + DX + DY + DZ + EX + EY + EZAX + AY + AZ = 0 (11.32 * (1-2 hand 100)-10) * AY + (12.83 * (1-3 hand 100)-10) * BY + (16.06 * (1-1 hand 100)-10) * CY + (5.68 * (1-1 hand 100)-10) * DY + (8.54 * (1-1 hand 100) -1x100)-10) * EY > = 0 (11.32 * (1-2x100)-10) * AZ + (12.83* (1-3Comp100)-10) * BZ + (16.06* (1-1Comp100)-10) * CZ + (5.68 * (1-1Unip 100)-10) * DZ + (8.54 * (1-1Unip 100)-10) * EZ > = 0 (6 * (1-2hand 100)-5) * AX + ( 4 * (1-3Comp100)-5) * BX + (5 * (1-1Uniq100)-5) * CX + (2 * (1-1mm100)-5) * DX + (5* (1-1lap100)-5) * EX = 15000

Third, when solving, the minimum value is calculated by default, and if you want to calculate the maximum value, add a negative sign, and the calculated value to remove the negative sign is the maximum value. Similar to-c in this paragraph:

Return op.linprog (- c, axiubu.. Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report