12 #include <Eigen/Eigen> 23 typedef Eigen::Matrix<double, Eigen::Dynamic, 1, Eigen::ColMajor, Eigen::Dynamic, 1> OptVector;
24 typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor, Eigen::Dynamic, Eigen::Dynamic> OptMatrix;
32 void initialize(
const char& type,
int rows,
int cols,
double lBnd,
double uBnd,
int& startIndexInOptVec );
33 void initialize(
const char& type,
int rows,
int cols, OptVector& lBnd, OptVector& uBnd,
int& startIndexInOptVec );
34 void initialize(
const char& type,
int rows,
int cols, OptMatrix& lBnd, OptMatrix& uBnd,
int& startIndexInOptVec );
35 void initialize(
const char& type,
int rows,
int cols,
double lBnd,
double uBnd,
int& startIndexInOptVec,
double guess );
36 void initialize(
const char& type,
int rows,
int cols,
double lBnd,
double uBnd,
int& startIndexInOptVec, OptMatrix& guess );
37 void initialize(
const char& type,
int rows,
int cols, OptVector& lBnd, OptVector& uBnd,
int& startIndexInOptVec, OptMatrix& guess );
38 void initialize(
const char& type,
int rows,
int cols, OptMatrix& lBnd, OptMatrix& uBnd,
int& startIndexInOptVec, OptMatrix& guess );
41 int id(
int row,
int col)
const {
return indexPosition_ + this->getColBndInd(col)*rows_ + this->
getRowBndInd(row); }
42 void constraintIndexToCurrentValue(
int index) { lBndMat_.col(index) = guessMat_.col(index); uBndMat_.col(index) = guessMat_.col(index); }
43 void setAndConstraintIndexToCurrentValue(
int index,
double value) { guessMat_.col(index).setConstant(value); this->constraintIndexToCurrentValue(index); }
44 void setAndConstraintIndexToCurrentValue(
int index, OptVector& value) { guessMat_.col(index) = value; this->constraintIndexToCurrentValue(index); }
45 void getValues(OptMatrix& lBnd, OptMatrix& uBnd, OptMatrix& guess,
int& size,
char& type)
const { lBnd = lBndMat_; uBnd = uBndMat_; guess = guessMat_; size = this->getNumElements(); type = type_; }
49 int getNumCols()
const {
return cols_; }
50 int getStartIndex()
const {
return indexPosition_; }
51 int getNumElements()
const {
return rows_*cols_; }
52 void getGuessValue(OptMatrix& guess)
const { guess.resize(rows_, cols_); guess = guessMat_; }
53 void getGuessValueByCol(
int index, OptVector& guess)
const { guess.resize(rows_,1); guess = guessMat_.col(index); }
54 void setGuessValue(
const OptMatrix& guess) { guessMat_ = guess.block(0,0,rows_,cols_); guessValueInitialized_ =
true; }
59 int getColBndInd(
int col)
const;
60 int getBlockLen(
int rini,
int cini,
int rend,
int cend)
const {
return this->
id(rend, cend) - this->
id(rini, cini) + 1; }
64 bool guessValueInitialized_;
65 int indexPosition_, rows_, cols_;
66 OptMatrix lBndMat_, uBndMat_, guessMat_;
OptimizationVariable()
Class constructor and destructor.
Definition: OptVar.hpp:28
int getNumRows() const
Some getter and setter methods.
Definition: OptVar.hpp:48
Class that contains all information about the optimization variables such as upper and lower bounds...
Definition: OptVar.hpp:20
int id(int row, int col) const
Some helper functions to construct the problem.
Definition: OptVar.hpp:41
void initialize(const char &type, int rows, int cols, double lBnd, double uBnd, int &startIndexInOptVec)
Some alternative initialization functions.
Definition: OptVar.cpp:14
int getRowBndInd(int row) const
Some helper functions to construct the problem.
Definition: OptVar.cpp:92