Ipopt 3.11.9
Loading...
Searching...
No Matches
SolveProblem.java
Go to the documentation of this file.
1
9package org.coinor.examples.scalable;
10
11import java.util.HashMap;
12import org.coinor.Ipopt;
13
19public 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}
int getStatus()
Gives Ipopt status of last OptimizeNLP call.
Definition Ipopt.java:320
int OptimizeNLP()
This function actually solve the problem.
Definition Ipopt.java:290
Implementation of Example 5.1 from "Sparse and Parially Separable Test Problems for Unconstrained and...
Abstract class for the scalable problems.
Definition Scalable.java:24
abstract boolean initialize(int n)
In this function all problem sizes, bounds and initial guess should be initialized.
void create()
Creates the problem based on the already computed problem sizes and bounds.
Definition Scalable.java:76
Class for running several different Scalable problems.