Bonmin 1.8.9
Loading...
Searching...
No Matches
BonTMINLPLinObj.hpp
Go to the documentation of this file.
1// (C) Copyright International Business Machines Corporation 2007
2// All Rights Reserved.
3//
4// Authors :
5// Pierre Bonami, International Business Machines Corporation
6//
7// Date : 08/16/2007
8
9
10#ifndef TMINLPLinObj_H
11#define TMINLPLinObj_H
12
13#include "BonTMINLP.hpp"
14
15namespace Bonmin {
40 public:
43
45 virtual ~TMINLPLinObj();
46
49
55 virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
56 Ipopt::Index& nnz_h_lag, Ipopt::TNLP::IndexStyleEnum& index_style);
60 virtual bool get_scaling_parameters(Ipopt::Number& obj_scaling,
61 bool& use_x_scaling, Ipopt::Index n,
62 Ipopt::Number* x_scaling,
63 bool& use_g_scaling, Ipopt::Index m,
64 Ipopt::Number* g_scaling);
65
66
68 virtual bool get_variables_types(Ipopt::Index n, VariableType* var_types){
69 assert(IsValid(tminlp_));
70 assert(n == n_);
71 var_types[n-1] = TMINLP::CONTINUOUS;
72 return tminlp_->get_variables_types(n - 1, var_types);
73 }
74
78 Ipopt::TNLP::LinearityType* const_types);
79
85
89 virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
90 bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
91 Ipopt::Index m, bool init_lambda,
92 Ipopt::Number* lambda);
93
96 virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
97 Ipopt::Number& obj_value){
98 assert(n == n_);
99 obj_value = x[n-1];
100 return true;}
101
104 virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
105 Ipopt::Number* grad_f){
106 assert(IsValid(tminlp_));
107 assert(n == n_);
108 n--;
109 for(int i = 0 ; i < n ; i++){
110 grad_f[i] = 0;}
111 grad_f[n] = 1;
112 return true;}
113
116 virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
118
122 virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
123 Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow,
124 Ipopt::Index *jCol, Ipopt::Number* values);
125
129 virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
130 Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
131 bool new_lambda, Ipopt::Index nele_hess,
132 Ipopt::Index* iRow, Ipopt::Index* jCol, Ipopt::Number* values);
135 virtual bool eval_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
140 virtual bool eval_grad_gi(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
141 Ipopt::Index i, Ipopt::Index& nele_grad_gi, Ipopt::Index* jCol,
142 Ipopt::Number* values);
144
146 assert(IsValid(tminlp_));
147 assert(n == n_);
148 bool r_val = tminlp_->get_variables_linearity(n-1, c);
149 c[n - 1] = Ipopt::TNLP::LINEAR;
150 return r_val;
151 }
152
153
158 Ipopt::Index n, const Ipopt::Number* x, Ipopt::Number obj_value){
159 return tminlp_->finalize_solution(status, n - 1, x,
160 obj_value);
161 }
163
165 virtual const BranchingInfo * branchingInfo() const{
166 return tminlp_->branchingInfo();
167 }
168
171 virtual const SosInfo * sosConstraints() const{
172 return tminlp_->sosConstraints();
173 }
175 virtual const PerturbInfo* perturbInfo() const
176 {
177 return tminlp_->perturbInfo();
178 }
179
182 assert(IsValid(tminlp_));
183 return tminlp_->hasUpperBoundingObjective();}
184
187 Ipopt::Number& obj_value){
188 assert(IsValid(tminlp_));
189 return tminlp_->eval_upper_bound_f(n - 1, x, obj_value); }
190
192 virtual bool hasLinearObjective(){return true;}
195 private:
197 void gutsOfDestructor();
198
202 int m_;
204 int n_;
206 int nnz_jac_;
208 int offset_;
209
210};
211
212
213}/* Ends Bonmin namepsace.*/
214
215#endif
216
From a TMINLP, this class adapts to another TMINLP where the original objective is transformed into a...
void setTminlp(Ipopt::SmartPtr< TMINLP > tminlp)
set reference TMINLP
virtual const BranchingInfo * branchingInfo() const
Use tminlp_ function.
virtual bool hasLinearObjective()
Say if problem has a linear objective (for OA)
virtual void finalize_solution(TMINLP::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, Ipopt::Number obj_value)
Use tminlp_ function.
Ipopt::SmartPtr< TMINLP > tminlp()
return pointer to tminlp_.
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)
Return the information about the bound on the variables and constraints.
virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
Return the vector of the gradient of the objective w.r.t.
virtual bool eval_h(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number *lambda, bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Return the hessian of the lagrangian.
virtual bool get_scaling_parameters(Ipopt::Number &obj_scaling, bool &use_x_scaling, Ipopt::Index n, Ipopt::Number *x_scaling, bool &use_g_scaling, Ipopt::Index m, Ipopt::Number *g_scaling)
Return scaling parameters.
virtual bool eval_upper_bound_f(Ipopt::Index n, const Ipopt::Number *x, Ipopt::Number &obj_value)
Use tminlp_ function.
virtual bool hasUpperBoundingObjective()
Use tminlp_ function.
virtual const SosInfo * sosConstraints() const
Use tminlp_ function.
virtual bool get_constraints_linearity(Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)
Return the constraints linearity.
virtual const PerturbInfo * perturbInfo() const
Use tminlp_ function.
virtual bool eval_grad_gi(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index i, Ipopt::Index &nele_grad_gi, Ipopt::Index *jCol, Ipopt::Number *values)
Compute the structure or values of the gradient for one constraint.
virtual bool get_variables_linearity(Ipopt::Index n, Ipopt::TNLP::LinearityType *c)
overload this method to provide the variables linearity.
TMINLPLinObj()
Default constructor.
virtual bool eval_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
Return the vector of constraint values.
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Return the value of the objective function.
virtual ~TMINLPLinObj()
destructor.
virtual bool eval_gi(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index i, Ipopt::Number &gi)
Compute the value of a single constraint.
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)
Return the number of variables and constraints, and the number of non-zeros in the jacobian and the h...
virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda)
Return the starting point.
virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Return the jacobian of the constraints.
virtual bool get_variables_types(Ipopt::Index n, VariableType *var_types)
Get the variable type.
Class to store perturbation radii for variables in the model.
Base class for all MINLPs that use a standard triplet matrix form and dense vectors.
Definition BonTMINLP.hpp:60
VariableType
Type of the variables.
SolverReturn
Return statuses of algorithm.
Definition BonTMINLP.hpp:64
(C) Copyright International Business Machines Corporation 2007
bool IsValid(const SmartPtr< U > &smart_ptr)
ipindex Index
ipnumber Number
Stores branching priorities information.
Class to store sos constraints for model.
Definition BonTMINLP.hpp:73