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

An example Analysis of Java Linear programming problem

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

Share

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

This article mainly explains the "example analysis of java linear programming problems". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn "Java linear programming problem example analysis" together.

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 the ibm component Cplex in java.

First of all, take a look at the official instructions, the limitations of the free version.

When you apply to download the free version, you should first register and fill in some information, and then send the download address to the mailbox at the time of the application. You can download win, linux and macos versions.

After this installation, there is an ide development tool CPLEX_Studio, and since I developed it with idea, I also need to configure the following steps:

After CPLEX_Studio is installed, there will be a jar package under the installation directory, which needs to be imported into our idea. I imported the jar package into my local maven repository and introduced it with pom:

Location of the jar package in CPLEX_Studio: d:\ CPLEX_Studio_Community201\ cplex\ lib\ cplex.jarmvn install:install-file-Dfile=D:\ CPLEX_Studio_Community201\ cplex\ lib\ cplex.jar-DgroupId=cplex-DartifactId=cplex-Dversion=20.1.0.0.R1-Dpackaging=jar cplex cplex 20.1.0.0.R1

Then add the java.library.path parameter to our startup project to specify the CPLEX runtime:

-Djava.library.path= "D:\ CPLEX_Studio_Community201\ cplex\ bin\ x64_win64"

I configured it directly with idea in development:

After that, it can be used happily.

The inequality equations in my 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-1Uniq100)-5) * DX + (5* (1-1Uniq100)-5) * EX

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