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  **********************************************************************************/
11 
12 #pragma once
13 
14 #include "ubpStructure.h"
15 
16 #include "babOptVar.h"
17 
18 #include "KTRException.h"
19 #include "KTRProblem.h"
20 #include "KTRSolver.h"
21 
22 #include <memory>
23 #include <vector>
24 
25 
26 namespace maingo {
27 
28 
29 namespace ubp {
30 
31 
32 struct DagObj;
33 
43 class KnitroProblem: public knitro::KTRProblem {
44  public:
57  KnitroProblem(unsigned nvarIn, unsigned neqIn, unsigned nineqIn, const unsigned nineqSquashIn, const std::vector<babBase::OptimizationVariable>& variables,
58  UbpStructure* structureIn, std::shared_ptr<std::vector<Constraint>> constraintPropertiesIn, std::shared_ptr<DagObj> dagObj);
59 
61  virtual ~KnitroProblem();
62 
72  double evaluateFC(const double* const x, double* const c, double* const objGrad, double* const jac);
73 
82  int evaluateGA(const double* const x, double* const objGrad, double* const jac);
83 
93  int evaluateHess(const double* const x, double objScaler, const double* const lambda, double* const hess);
94 
95  private:
100 
104  void _setVariableProperties();
105 
110 
115 
120  unsigned _nvar;
121  unsigned _nineq;
122  unsigned _nineqSquash;
123  unsigned _neq;
125  std::shared_ptr<std::vector<Constraint>> _constraintProperties;
126  std::vector<babBase::OptimizationVariable> _optimizationVariables;
127  std::shared_ptr<DagObj> _DAGobj;
130 
132 
133 
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:126
KnitroProblem(unsigned nvarIn, unsigned neqIn, unsigned nineqIn, const unsigned nineqSquashIn, const std::vector< babBase::OptimizationVariable > &variables, UbpStructure *structureIn, std::shared_ptr< std::vector< Constraint >> constraintPropertiesIn, std::shared_ptr< DagObj > dagObj)
Constructor actually used in ubp.cpp. Initializes the corresponding members.
Class for representing problems to be solved by Knitro, providing an interface to the problem definit...
Definition: knitroProblem.h:43
unsigned _nvar
Definition: knitroProblem.h:120
UbpStructure * _structure
Definition: knitroProblem.h:124
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.
namespace holding all essentials of MAiNGO
Definition: aleModel.h:25
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:123
virtual ~KnitroProblem()
Destructor.
Struct for storing structure information for the upper bounding solver.
Definition: ubpStructure.h:30
unsigned _nineqSquash
Definition: knitroProblem.h:122
unsigned _nineq
Definition: knitroProblem.h:121
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.
std::shared_ptr< std::vector< Constraint > > _constraintProperties
Definition: knitroProblem.h:125