MAiNGO
knitroProblem.h
Go to the documentation of this file.
1 /**********************************************************************************
2  * Copyright (c) 2019 Process Systems Engineering (AVT.SVT), RWTH Aachen University
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License 2.0 which is available at
6  * http://www.eclipse.org/legal/epl-2.0.
7  *
8  * SPDX-License-Identifier: EPL-2.0
9  *
10  * @file knitroProblem.h
11  *
12  * @brief File containing declaration of problem class used by Knitro.
13  *
14  **********************************************************************************/
15 
16 #pragma once
17 
18 #include "ubpStructure.h"
19 
20 #include "babOptVar.h"
21 
22 #include "KTRException.h"
23 #include "KTRProblem.h"
24 #include "KTRSolver.h"
25 
26 #include <memory>
27 #include <vector>
28 
29 
30 namespace maingo {
31 
32 
33 namespace ubp {
34 
35 
36 struct DagObj;
37 
47 class KnitroProblem: public knitro::KTRProblem {
48  public:
61  KnitroProblem(unsigned nvarIn, unsigned neqIn, unsigned nineqIn, const unsigned nineqSquashIn, const std::vector<babBase::OptimizationVariable>& variables,
62  UbpStructure* structureIn, std::vector<Constraint>* constraintPropertiesIn, std::shared_ptr<DagObj> dagObj);
63 
65  virtual ~KnitroProblem();
66 
76  double evaluateFC(const double* const x, double* const c, double* const objGrad, double* const jac);
77 
86  int evaluateGA(const double* const x, double* const objGrad, double* const jac);
87 
97  int evaluateHess(const double* const x, double objScaler, const double* const lambda, double* const hess);
98 
99  private:
104 
108  void _setVariableProperties();
109 
114 
119 
124  unsigned _nvar;
125  unsigned _nineq;
126  unsigned _nineqSquash;
127  unsigned _neq;
129  std::vector<Constraint>* _constraintProperties;
130  std::vector<babBase::OptimizationVariable> _optimizationVariables;
131  std::shared_ptr<DagObj> _DAGobj;
134 
136 
137 
double evaluateFC(const double *const x, double *const c, double *const objGrad, double *const jac)
Function called by Knitro to get values of the objective and constraints at a point x.
int evaluateGA(const double *const x, double *const objGrad, double *const jac)
Function called by Knitro to get derivatives of the objective and constraints at point x.
std::vector< babBase::OptimizationVariable > _optimizationVariables
Definition: knitroProblem.h:130
Class for representing problems to be solved by Knitro, providing an interface to the problem definit...
Definition: knitroProblem.h:47
unsigned _nvar
Definition: knitroProblem.h:124
std::vector< Constraint > * _constraintProperties
Definition: knitroProblem.h:129
UbpStructure * _structure
Definition: knitroProblem.h:128
void _setObjectiveProperties()
Set properties of objective function, i.e., type (linear, quadratic, general)
void _setDerivativeProperties()
Set properties of derivatives, i.e., correct indices for non zeros in Jacobian.
KnitroProblem(unsigned nvarIn, unsigned neqIn, unsigned nineqIn, const unsigned nineqSquashIn, const std::vector< babBase::OptimizationVariable > &variables, UbpStructure *structureIn, std::vector< Constraint > *constraintPropertiesIn, std::shared_ptr< DagObj > dagObj)
Constructor actually used in ubp.cpp. Initializes the corresponding members.
namespace holding all essentials of MAiNGO
Definition: aleModel.h:31
void _setConstraintProperties()
Set properties of constraints, i.e., bounds and type (linear, quadratic, general)
void _setVariableProperties()
Set properties of variables, i.e., type (continuous, binary, integer)
unsigned _neq
Definition: knitroProblem.h:127
virtual ~KnitroProblem()
Destructor.
Struct for storing structure information for the upper bounding solver.
Definition: ubpStructure.h:35
unsigned _nineqSquash
Definition: knitroProblem.h:126
unsigned _nineq
Definition: knitroProblem.h:125
int evaluateHess(const double *const x, double objScaler, const double *const lambda, double *const hess)
Function called by Knitro to get the hessian of the lagrangian at point x.