Skip to content
Snippets Groups Projects
Commit ca3f6f40 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Revert "Accessors and documentation"

This reverts commit 653b4b0a.
parent c44d805b
No related branches found
No related tags found
No related merge requests found
......@@ -57,54 +57,63 @@ QPProblem_s::QPProblem_s():
QPProblem_s::~QPProblem_s()
{
releaseMemory();
ReleaseMemory();
}
void QPProblem_s::releaseMemory()
void QPProblem_s::ReleaseMemory()
{
if (Q!=0)
delete [] Q;
if (D!=0)
delete [] D;
if (DS!=0)
delete [] DS;
if (DU!=0)
delete [] DU;
if (XL!=0)
delete [] XL;
if (XU!=0)
delete [] XU;
if (X!=0)
delete [] X;
if (iwar!=0)
delete [] iwar;
if (war!=0)
delete [] war;
if (U!=0)
delete [] U;
}
void
QPProblem_s::resizeAll( int nb_variables, int nb_constraints)
QPProblem_s::resizeAll( int NbVariables, int NbConstraints)
{
resize(Q,2*n*n,2*nb_variables*nb_variables); //Quadratic part of the objective function
resize(D,2*n,2*nb_variables); // Linear part of the objective function
resize(Q,2*n*n,2*NbVariables*NbVariables); //Quadratic part of the objective function
resize(D,2*n,2*NbVariables); // Linear part of the objective function
resize(DS,2*m,2*nb_constraints);
resize(DU,2*m*n,2*nb_variables*nb_constraints);
resize(DS,2*m,2*NbConstraints);
resize(DU,2*m*n,2*NbVariables*NbConstraints);
resize(XL,2*n,2*nb_variables); // Lower bound on the solution.
initialize(XL,2*nb_variables,-1e8);
resize(XU,2*n,2*nb_variables); // Upper bound on the solution.
initialize(XU,2*nb_variables,1e8);
resize(XL,2*n,2*NbVariables); // Lower bound on the solution.
initialize(XL,2*NbVariables,-1e8);
resize(XU,2*n,2*NbVariables); // Upper bound on the solution.
initialize(XU,2*NbVariables,1e8);
resize(X,2*n,2*nb_variables); // Solution of the problem.
resize(U,2*mnn,2*(nb_constraints+2*nb_variables));
resize(X,2*n,2*NbVariables); // Solution of the problem.
resize(U,2*mnn,2*(NbConstraints+2*NbVariables));
resize(war,2*lwar,2*(3*nb_variables*nb_variables/2+ 10*nb_variables + 2*(nb_constraints+1) + 20000));
resize(iwar,2*liwar,2*nb_variables); // The Cholesky decomposition is done internally.
resize(war,2*lwar,2*(3*NbVariables*NbVariables/2+ 10*NbVariables + 2*(NbConstraints+1) + 20000));
resize(iwar,2*liwar,2*NbVariables); // The Cholesky decomposition is done internally.
}
......@@ -313,28 +322,28 @@ void QPProblem_s::addTerm( const MAL_VECTOR (&Vec, double), int type,
unsigned int row )
{
double * array;
double * aArray;
unsigned int max_rows;
switch(type)
{
case VECTOR_D:
array = D;
aArray = D;
max_rows = n;
break;
case VECTOR_XL:
array = XL;
aArray = XL;
max_rows = n;
break;
case VECTOR_XU:
array = XU;
aArray = XU;
max_rows = n;
break;
case VECTOR_DS:
array = DS;
aArray = DS;
max_rows = mmax;
break;
}
......@@ -348,7 +357,7 @@ void QPProblem_s::addTerm( const MAL_VECTOR (&Vec, double), int type,
}
for(unsigned int i = 0;i < Vec.size(); i++)
array[row+i] += Vec(i);
aArray[row+i] += Vec(i);
}
......@@ -407,48 +416,48 @@ QPProblem_s::dump( int type, std::ostream & aos)
{
int lnbrows=0, lnbcols=0;
double * array=0;
double * aArray=0;
std::string Name;
switch(type)
{
case MATRIX_Q:
lnbrows = lnbcols = n ;
array = Q;
aArray = Q;
Name = "Q";
break;
case MATRIX_DU:
lnbrows = mmax;
lnbcols = n;
array = DU;
aArray = DU;
Name = "DU";
break;
case VECTOR_D:
lnbrows = n;
lnbcols = 1 ;
array = D;
aArray = D;
Name = "D";
break;
case VECTOR_XL:
lnbrows = n;
lnbcols = 1;
array = XL;
aArray = XL;
Name = "XL";
break;
case VECTOR_XU:
lnbrows = n;
lnbcols=1;
array = XU;
aArray = XU;
Name = "XU";
break;
case VECTOR_DS:
lnbrows = m;
lnbcols= 1;
array = DS;
aArray = DS;
Name = "DS";
break;
}
......@@ -458,7 +467,7 @@ QPProblem_s::dump( int type, std::ostream & aos)
for(int i=0;i<lnbrows;i++)
{
for(int j=0;j<lnbcols;j++)
aos << array[i+j*lnbrows] << " ";
aos << aArray[i+j*lnbrows] << " ";
aos << std::endl;
}
aos << std::endl;
......
......@@ -116,22 +116,8 @@ namespace PatternGeneratorJRL
~QPProblem_s();
/// \brief Set the number of optimization parameters.
///
/// \param nb_variables
inline void setNbVariables( int nb_variables )
{ m_NbVariables = n = nb_variables;};
/// \brief Set the number of optimization parameters.
///
/// \param nb_variables
inline void setNbEqConstraints( int nb_eq_constraints )
{ m_NbEqConstraints = me = nb_eq_constraints;};
/// \brief Set the number of optimization parameters.
///
/// \param nb_variables
inline void setNbConstraints( int nb_constraints )
{ m_NbVariables = n = nb_constraints;};
inline void setNbVariables( int NbVariables )
{ m_NbVariables = NbVariables;};
/// \brief Set the dimensions of the problem.
/// This method has an internal logic to
......@@ -185,8 +171,6 @@ namespace PatternGeneratorJRL
void addTerm(const MAL_VECTOR (&Vec, double), int type,
unsigned int row);
/// \name Dumping functions
/// \{
/// \brief Print of disk the parameters that are passed to the solver
void dumpSolverParameters(std::ostream & aos);
......@@ -200,35 +184,27 @@ namespace PatternGeneratorJRL
/// \param filename
void dump( int type, const char *filename);
void dump( int type, std::ostream &);
/// \}
/// \brief Initialize array
///
/// \param[out] array
/// \param[in] size
/// \param array
/// \param size
template <class type> void initialize(type * array, int size, type value)
{ std::fill_n(array,size,value); }
/// \brief Initialize whole array
///
/// \param[in] type
void clear( int type );
/// \param type
void clear(const int type);
/// \brief Initialize block of matrix-array
///
/// \param[in] type
/// \param[in] row
/// \param[in] col
/// \param[in] nb_rows
/// \param[in] nb_cols
/// \param type
void clear( int type,
int row, int col,
int nb_rows, int nb_cols);
/// \brief Solve the problem
///
/// \param[in] solver
/// \param[out] result
void solve( int solver, solution_t & result);
//
......@@ -236,39 +212,31 @@ namespace PatternGeneratorJRL
//
protected:
/// \brief Relese memory.
void releaseMemory();
/// The method doing the real job of releasing the memory.
void ReleaseMemory();
/// \brief Allocate memory.
/// The method allocating the memory.
/// Called when setting the dimensions of the problem.
///
/// \param nb_variables
/// \param nb_constraints
void resizeAll( int nb_variables, int nb_constraints);
void resizeAll( int NbVariables, int NbConstraints);
//
//Private members
//
private:
/// \name ql-parameters
/// \{
/// \brief QLD parameters
int m, me, mmax, n, nmax, mnn;
double *Q, *D, *DU, *DS, *XL, *XU, *X, *U, *war;
double *Q, *D, *DU, *DS, *XL, *XU, *X, *U, *war;//For COM
int *iwar;
int iout, ifail, iprint, lwar, liwar;
double Eps;
/// \}
/// \brief Number of optimization parameters
int m_NbVariables;
/// \brief Total number of constraints
/// \brief Number of optimization parameters
int m_NbConstraints;
/// \brief Number of equality constraints
int m_NbEqConstraints;
/// \brief Reallocation margins
int m_ReallocMarginVar, m_ReallocMarginConstr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment