BonTMINLP.cpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines (IBM) 2005, 2007
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, IBM
7 //
8 // Date : 26/09/2006
9 
10 #include "BonTMINLP.hpp"
11 #include "IpBlas.hpp"
12 #include "BonTypes.hpp"
13 
14 namespace Bonmin{
15 
18  num(0),
19  types(NULL),
20  priorities(NULL),
21  numNz(0),
22  starts(NULL),
23  indices(NULL),
24  weights(NULL)
25 {}
26 
29  num(source.num),
30  types(NULL),
31  priorities(NULL),
32  numNz(source.numNz),
33  starts(NULL),
34  indices(NULL),
35  weights(NULL)
36 {
37 
38  if(num > 0) {
39  assert(source.types!=NULL);
40  assert(source.priorities!=NULL);
41  assert(source.starts!=NULL);
42  assert(source.indices!=NULL);
43  assert(source.weights!=NULL);
44  types = new char[num];
45  priorities = new int[num];
46  starts = new int[num + 1];
47  indices = new int[numNz];
48  weights = new double[numNz];
49  for(int i = 0 ; i < num ; i++) {
50  source.types[i] = types[i];
51  source.priorities[i] = priorities[i];
52  source.starts[i] = starts[i];
53  }
54  for(int i = 0 ; i < numNz ; i++) {
55  source.indices[i] = indices[i];
56  source.weights[i] = weights[i];
57  }
58  }
59  else {
60  assert(source.types==NULL);
61  assert(source.priorities==NULL);
62  assert(source.starts==NULL);
63  assert(source.indices==NULL);
64  assert(source.weights==NULL);
65  }
66 
67 }
68 
69 
71 void
73 {
74  num = 0;
75  numNz = 0;
76  if(types) delete [] types;
77  types = NULL;
78  if(starts) delete [] starts;
79  starts = NULL;
80  if(indices) delete [] indices;
81  indices = NULL;
82  if(priorities) delete [] priorities;
83  priorities = NULL;
84  if(weights) delete [] weights;
85  weights = NULL;
86 }
87 
88 
89 void TMINLP::PerturbInfo::SetPerturbationArray(Ipopt::Index numvars, const double* perturb_radius) {
90  delete [] perturb_radius_;
91  if (perturb_radius) {
92  perturb_radius_ = new double[numvars];
93  for(int i=0; i<numvars; i++) {
94  perturb_radius_[i] = perturb_radius[i];
95  }
96  }
97 }
98 
100 {}
101 
102 TMINLP::TMINLP(const TMINLP & source)
103 {
104 }
105 
108 {
109 }
110 
112 bool
114  int n, m, nnz_j, nnz_h;
115  Ipopt::TNLP::IndexStyleEnum dummy;
116  get_nlp_info(n, m, nnz_j, nnz_h, dummy);
117  vector<double> x_lb(n);
118  vector<double> x_ub(n);
119  vector<double> g_lb(m);
120  vector<double> g_ub(m);
121  vector<VariableType> v_t(n);
122  get_variables_types(n, v_t());
123  get_bounds_info(n, x_lb(), x_ub(), m, g_lb(), g_ub());
124  for(int i = 0 ; i < n ; i++){
125  if(v_t[i] == INTEGER &&
126  (x_lb[i] < - 0.99 || x_lb[i] > 0.99 ||
127  x_ub[i] <0.01 || x_ub[i] > 1.99) ){
128  return true;
129  }
130  }
131  return false;
132 }
133 
134 }
Base class for all MINLPs that use a standard triplet matrix form and dense vectors.
Definition: BonTMINLP.hpp:59
int num
Number of SOS constraints.
Definition: BonTMINLP.hpp:75
virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)=0
overload this method to return the information about the bound on the variables and constraints...
virtual bool get_variables_types(Ipopt::Index n, VariableType *var_types)=0
overload this method to provide the variables types.
TMINLP()
Default destructor.
Definition: BonTMINLP.cpp:99
Class to store sos constraints for model.
Definition: BonTMINLP.hpp:72
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, Ipopt::TNLP::IndexStyleEnum &index_style)=0
overload this method to return the number of variables and constraints, and the number of non-zeros i...
int * starts
For 0 &lt;= i &lt; nums, start[i] gives the indice of indices and weights arrays at which the description o...
Definition: BonTMINLP.hpp:86
int numNz
Total number of non zeroes in SOS constraints.
Definition: BonTMINLP.hpp:84
virtual ~TMINLP()
Default destructor.
Definition: BonTMINLP.cpp:107
int * priorities
priorities of sos constraints.
Definition: BonTMINLP.hpp:79
char * types
Type of sos.
Definition: BonTMINLP.hpp:77
bool hasGeneralInteger()
Say if problem has general integer variables.
Definition: BonTMINLP.cpp:113
int * indices
indices of elements belonging to the SOS.
Definition: BonTMINLP.hpp:88
void SetPerturbationArray(Ipopt::Index numvars, const double *perturb_radius)
Method for setting the perturbation radii.
Definition: BonTMINLP.cpp:89
static fint nnz_h
void fint * m
void fint * n
void gutsOfDestructor()
Reset information.
Definition: BonTMINLP.cpp:72
SosInfo()
default constructor.
Definition: BonTMINLP.cpp:17
double * weights
weights of the elements of the SOS.
Definition: BonTMINLP.hpp:90