简体   繁体   English

将Excel求解器转换为Java

[英]Convert Excel solver to java

I am trying to convert a Excel Solver solution to a java app 我正在尝试将Excel Solver解决方案转换为Java应用程序

The excel solver is Excel求解器是

Solver Parameters:
Set Objective: D24 to Max
By Changing Variable Cells: C4:C23
Subject to the Constraints:
C24 = B24
L24 <= N24
L25 >= N25
(non-negative)
GRG Nonlinear

I have been goggling for sometime and cannot find a java library to achieve this. 我闲逛了一段时间,找不到Java库来实现这一目标。 Any ideas? 有任何想法吗?

I have tried choco-solver http://www.emn.fr/z-info/choco-solver/ 我已经尝试过choco-solver http://www.emn.fr/z-info/choco-solver/

    Solver solver = new Solver("my first problem");
    // 2. Create variables through the variable factory 
    IntVar x = VariableFactory.bounded("X", 0, 5, solver);
    IntVar y = VariableFactory.bounded("Y", 0, 5, solver);
    // 3. Create and post constraints by using constraint factories
    solver.post(IntConstraintFactory.arithm(x, "+", y, "<", 5)); 
    // 4. Define the search strategy
    solver.set(IntStrategyFactory.inputOrder_InDomainMin(new IntVar[]{x,y} )); 
    // 5. Launch the resolution process
      if (solver.findSolution()) {
            do {
                prettyOut();
            }
            while (solver.nextSolution());
        }

I am finding it difficult to relate this to the Excel solver functions, my math is not great 我发现很难将其与Excel求解器函数关联,我的数学不是很好

If you are looking for an API to read and write to microsoft documents, take a look at Apache POI: 如果您正在寻找读写Microsoft文档的API,请查看Apache POI:

http://poi.apache.org/ http://poi.apache.org/
http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/ http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/

There is a Simplexsolver implementation in Apache Commons Math , but I can't say anything on performance or possible problem size. Apache Commons Math中有一个Simplexsolver实现 ,但是我不能说任何有关性能或可能出现的问题的大小。 Finding non-propertery solutions for optimization problems, can be tricky because it is very difficult to efficently optimize large problem sizes and it is an ongoing field of research with only a hand full of good commerical/research solutions. 由于很难有效地优化大问题的大小,而且很难找到有效的优化非商业解决方案的方法,因此这是一个持续不断的研究领域,只有大量的好的商业/研究解决方案。

If you want to keep excelfiles as input you need to parse the data and convert it. 如果要保留excelfile作为输入,则需要解析数据并将其转换。 For reading Excel files you can use Apache POI . 要读取Excel文件,可以使用Apache POI

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

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