File: Scalable.java

package info (click to toggle)
coinor-ipopt 3.14.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,796 kB
  • sloc: cpp: 97,169; sh: 4,802; ansic: 2,537; java: 1,289; makefile: 821; fortran: 224; xml: 210
file content (95 lines) | stat: -rw-r--r-- 2,165 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* Copyright (C) 2007 VRTech Industrial Technologies - www.vrtech.com.br.
 * Copyright (C) 2007 Tong Kewei, Beihang University, - www.buaa.edu.cn.
 * All Rights Reserved.
 * This code is published under the Eclipse Public License.
 */

import org.coinor.Ipopt;

/**
 * Abstract class for the scalable problems.
 *
 * Implementations should derive from this class and implement
 * {@link #initialize(int)} where all problem size, bounds, and inital guess
 * should be initialized. Besides the initialization, the abstract functions for
 * evaluation of objective, bounds, etc need to be implemented.
 *
 * @author Rafael de Pelegrini Soares, Tong Kewei
 */
public abstract class Scalable extends Ipopt
{
   // Problem sizes
   int n;
   int m;
   int nnz_jac_g;
   int nnz_h_lag;

   // The bounds
   double x_l[], x_u[];
   double g_l[], g_u[];

   // the index style
   int index_style;

   // The initial guess and solution
   double x[];

   private String name;

   protected double gl;
   protected double gu;

   /** Constructor.
    * @param name name of example
    * @param gl the constraint lower bound value for all elements of g
    * @param gu the constraint upper bound value for all elements of g
    */
   public Scalable(
      String name,
      double gl,
      double gu)
   {
      this.name = name;
      this.gl = gl;
      this.gu = gu;
   }

   public String toString()
   {
      return name;
   }

   /** In this function all problem sizes, bounds and initial guess should be initialized.
    *
    * @param n the problem size
    *
    * @return true if the given size is valid for this problem
    */
   abstract public boolean initialize(
      int n
   );

   /** Creates the problem based on the already computed problem sizes and bounds.
    */
   public void create()
   {
      super.create(n, m, nnz_jac_g, nnz_h_lag, index_style);
   }

   public double[] getInitialGuess()
   {
      return x;
   }

   protected void print(
      double[] x,
      String   str)
   {
      System.out.println(str);
      for( int i = 0; i < x.length; ++i )
      {
         System.out.println(x[i]);
      }
      System.out.println();
   }
}