简体   繁体   中英

Convert Excel solver to java

I am trying to convert a Excel Solver solution to a java app

The excel solver is

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. Any ideas?

I have tried 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

If you are looking for an API to read and write to microsoft documents, take a look at Apache POI:

http://poi.apache.org/
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. 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. For reading Excel files you can use Apache POI .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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