Ipopt  3.12.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SolveProblem.java
Go to the documentation of this file.
1 
9 package org.coinor.examples.scalable;
10 
11 import java.util.HashMap;
12 import org.coinor.Ipopt;
13 
19 public class SolveProblem
20 {
21  public static void main(String[] args)
22  {
23  HashMap<String, Scalable> list = new HashMap<String, Scalable>();
24 
25  // adding all problems here
26  list.put("LukVlE1", new LuksanVlcek1("LukVlE1", 0.0, 0.0));//E means equal
27  list.put("LukVlI1", new LuksanVlcek1("LukVlI1", -1.0, 0.0));//I means inequal
28 
29  if( args.length < 2 )
30  {
31  System.out.println("Usage: ProblemName N\n");
32  System.out.println(" - N is a positive parameter determining problem size");
33  System.out.println(" - ProblemName is one of:");
34  // list all problems
35  for( Scalable s : list.values() )
36  System.out.println(" " + s);
37 
38  return;
39  }
40 
41  String problem = args[0];
42  int n = Integer.parseInt(args[1]);
43 
44  System.out.println("Solving problem " + problem + " for N=" + n);
45 
46  Scalable p = list.get(problem);
47  if( p == null )
48  {
49  System.out.println("Problem not found!");
50  return;
51  }
52 
53  if( !p.initialize(n) )
54  return;
55 
56  p.create();
57 
58  p.OptimizeNLP();
59 
60  switch( p.getStatus() )
61  {
62  case Ipopt.SOLVE_SUCCEEDED:
63  case Ipopt.ACCEPTABLE_LEVEL:
64  System.out.println("Solution found.");
65  break;
66  default:
67  System.out.println("** Could not solve problem " + problem + " for N=" + n + ", status: " + p.getStatus());
68  }
69  }
70 }
Implementation of Example 5.1 from &quot;Sparse and Parially Separable Test Problems for Unconstrained and...
Abstract class for the scalable problems.
Definition: Scalable.java:23
Class for running several different Scalable problems.
A Java Native Interface for the Ipopt optimization solver.
Definition: Ipopt.java:47