- Main Page
- Classes
- Files

- File List
- File Members

# contrib/JavaInterface/org/coinor/examples/scalable/SolveProblem.java

Go to the documentation of this file.

    00001
    00009 package org.coinor.examples.scalable;
    00010
    00011 import java.util.HashMap;
    00012 import org.coinor.Ipopt;
    00013
    00019 public class SolveProblem
    00020 {
    00021     public static void main(String[] args)
    00022     {
    00023         HashMap<String, Scalable> list = new HashMap<String, Scalable>();
    00024
    00025         // adding all problems here
    00026         list.put("LukVlE1", new LuksanVlcek1("LukVlE1",  0.0, 0.0));//E means equal
    00027         list.put("LukVlI1", new LuksanVlcek1("LukVlI1", -1.0, 0.0));//I means inequal
    00028
    00029         if( args.length < 2 )
    00030         {
    00031             System.out.println("Usage: ProblemName N\n");
    00032             System.out.println("  - N is a positive parameter determining problem size");
    00033             System.out.println("  - ProblemName is one of:");
    00034             // list all problems
    00035             for( Scalable s : list.values() )
    00036                 System.out.println("       " + s);
    00037
    00038             return;
    00039         }
    00040
    00041         String problem = args[0];
    00042         int n = Integer.parseInt(args[1]);
    00043
    00044         System.out.println("Solving problem " + problem + " for N=" + n);
    00045
    00046         Scalable p = list.get(problem);
    00047         if( p == null )
    00048         {
    00049             System.out.println("Problem not found!");
    00050             return;
    00051         }
    00052
    00053         if( !p.initialize(n) )
    00054             return;
    00055
    00056         p.create();
    00057
    00058         p.OptimizeNLP();
    00059
    00060         switch( p.getStatus() )
    00061         {
    00062             case Ipopt.SOLVE_SUCCEEDED:
    00063             case Ipopt.ACCEPTABLE_LEVEL:
    00064                 System.out.println("Solution found.");
    00065                 break;
    00066             default:
    00067                 System.out.println("** Could not solve problem " + problem + " for N=" + n + ", status: " + p.getStatus());
    00068         }
    00069     }
    00070 }

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines