EnergyMinimization Class Reference

#include <EnergyMinimization.h>

List of all members.


Detailed Description

This class uses MOSEK library to solve non-linear convex minimization problem.

In order to find flat (or piecewise flat) triangulation of the input surface, valid radii of the circumcircles of the triangles need to be computed. This is done by minimizing convex functional. This class creates MOSEK minimization task that uses functions defined in CirclePattern class to do the minimization.

Definition at line 23 of file EnergyMinimization.h.

Public Member Functions

 EnergyMinimization (Mesh *_mesh, const MSKenv_t &env)
 Creates circle pattern energy minimization task.
void doSolve ()
 This function calls rutines to perform circle pattern energy minimization.
 ~EnergyMinimization (void)
 Delete MOSEK arrays allocated for minimization.

Private Member Functions

void setDataStructres ()
 Define constraints and free bounds for the variables.
void minimize ()
 Calls MOSEK functions to perform minimization.
void allocateMosekArrays ()
 Allocate arrays that MOSEK uses for minimization.
void clearMosekArrays ()
 Delete arrays that MOSEK uses for minimization.

Private Attributes

Meshmesh
MSKtask_t task
int NUMCON
 Number of constraints.
int NUMVAR
 Number of variables.
int NUMANZ
 Number of nonzeros i A.
int * bkc
 Type of the constraint.
double * blc
 Lower bound on the constraint.
double * buc
 Upper bound on the constraint.
int * ptrb
 For represenations of sparse constraint matrix: beginning of the row.
int * ptre
 For represenations of sparse constraint matrix: ending of the row.
int * sub
 For represenations of sparse constraint matrix: subscipts for nonzero values in the row.
double * val
 For represenations of sparse constraint matrix: values in the matrix.
int * bkx
 Type of the constraint on the variable.
double * blx
 Lower bound on the variable.
double * bux
 Upper bound on the variable.
double * c
 Linear minimization part.
double * xx
 Variable that we optimize for - radii of circum centers of triangles.


Constructor & Destructor Documentation

EnergyMinimization::EnergyMinimization Mesh _mesh,
const MSKenv_t &  env
 

Creates circle pattern energy minimization task.

Computes number of variables, constraints, number of non-zeros in constraint matrix, sets functions to compute energy, gradient and hessian.

Definition at line 116 of file EnergyMinimization.cpp.

00116                                                                          {
00117    mesh = _mesh;
00118 
00119    NUMVAR = mesh->numFaces();
00120    NUMCON = 1;
00121    NUMANZ = NUMVAR;
00122 
00124    int r = MSK_RES_OK;
00125    r = MSK_maketask(env, NUMCON, NUMVAR, &task);
00126    check_error (r != MSK_RES_OK, "Cannot make MOSEK task for radii energy minimization.");
00127    r = MSK_linkfiletotaskstream(task, MSK_STREAM_LOG, "_RadiiMinMosekOut.txt", 0);
00128    check_error (r != MSK_RES_OK, "Cannot link MOSEK \"_RadiiMinMosekOut.txt\" output file.");
00129 }

EnergyMinimization::~EnergyMinimization void   )  [inline]
 

Delete MOSEK arrays allocated for minimization.

Definition at line 132 of file EnergyMinimization.h.

00132 { clearMosekArrays(); }


Member Function Documentation

void EnergyMinimization::allocateMosekArrays  )  [private]
 

Allocate arrays that MOSEK uses for minimization.

Definition at line 192 of file EnergyMinimization.cpp.

00192                                              {
00193    bkc = new int[NUMCON];
00194    bkx = new int[NUMVAR];
00195    ptrb = new int[NUMVAR];
00196    ptre = new int[NUMVAR];
00197    sub = new int[NUMANZ];
00198    blc = new double[NUMCON];
00199    buc = new double[NUMCON];
00200    c = new double[NUMVAR];
00201    blx = new double[NUMVAR];
00202    bux = new double[NUMVAR];
00203    val = new double[NUMANZ];
00204    xx = new double[NUMVAR];
00205 }

void EnergyMinimization::clearMosekArrays  )  [private]
 

Delete arrays that MOSEK uses for minimization.

Definition at line 207 of file EnergyMinimization.cpp.

00207                                           {
00208    if (task) {
00209 
00210       delete [] bkc;
00211       delete [] bkx;
00212       delete [] ptrb;
00213       delete [] ptre;
00214       delete [] sub;
00215       delete [] blc;
00216       delete [] buc;
00217       delete [] c;
00218       delete [] blx;
00219       delete [] bux;
00220       delete [] val;
00221       MSK_deletetask(&task);
00222       task = NULL;
00223    }
00224 }

void EnergyMinimization::doSolve  ) 
 

This function calls rutines to perform circle pattern energy minimization.

Definition at line 131 of file EnergyMinimization.cpp.

00131                                  {
00132    allocateMosekArrays();
00133    setDataStructres();
00134    minimize();   
00135 }

void EnergyMinimization::minimize  )  [private]
 

Calls MOSEK functions to perform minimization.

Input constraint data.

Input nonlinear function information.

Perform optimization

Save solution

Definition at line 162 of file EnergyMinimization.cpp.

00162                                   {
00163    int r = MSK_RES_OK;
00164 
00166    r = MSK_inputdata(task, NUMCON, NUMVAR, NUMCON, NUMVAR, c, 0.0, ptrb, ptre, sub, val, bkc, blc, buc, bkx, blx, bux);
00167    check_error ( r != MSK_RES_OK, 
00168       "Could not input constraints for radii minimization.\n Check  \"RadiiMinMosekOut.txt\" for output." );
00169 
00171    r = MSK_putnlfunc(task, mesh, nlspar, nleval);
00172    check_error ( r != MSK_RES_OK, 
00173       "Could not input nonlinear function for radii minimization.\n Check  \"RadiiMinMosekOut.txt\" for output." );
00174 
00176    r = MSK_optimize(task);
00177    check_error ( r != MSK_RES_OK, 
00178       "Could not solve for radii minimization.\n Check  \"RadiiMinMosekOut.txt\" for output." );
00179 
00180    r = MSK_getsolutionslice(task, MSK_SOL_ITR, MSK_SOL_ITEM_XX, 0, NUMVAR, xx);
00181    check_error ( r != MSK_RES_OK, "Could not get radii solution.\n Check  \"RadiiMinMosekOut.txt\" for output." );
00182 
00183    MSK_solutionsummary(task, MSK_STREAM_ERR);
00184 
00186    Mesh::FaceIterator fIter = mesh->faceIterator();
00187    for (int i = 0; !fIter.end(); fIter++) { 
00188       fIter.face()->r = exp(xx[i++]);
00189    }
00190 }

void EnergyMinimization::setDataStructres  )  [private]
 

Define constraints and free bounds for the variables.

The only constraint for the optimization $\sum_{f \in F}\rho_f = 0$ (removes scaling direction). For most of the non-linear solvers this constraint is not necessary, as they would not move in the direction that does not change the energy anyway.

Definition at line 137 of file EnergyMinimization.cpp.

00137                                           {
00145    bkc[0] = MSK_BK_FX;
00146    blc[0] = 0.0;
00147    buc[0] = 0.0;
00148 
00151    for (int i = 0; i < NUMVAR; i++){
00152       c[i]     = 1.0;
00153       ptrb[i]  = i;  ptre[i] = i+1;
00154       sub[i]   = 0;  val[i]  = 1.0;
00155 
00156       bkx[i]   = MSK_BK_FR;
00157       blx[i]   = -MSK_INFINITY;
00158       bux[i]   = MSK_INFINITY;
00159    }
00160 }


Member Data Documentation

int* EnergyMinimization::bkc [private]
 

Type of the constraint.

Size: NUMCON

Definition at line 59 of file EnergyMinimization.h.

int* EnergyMinimization::bkx [private]
 

Type of the constraint on the variable.

Size: NUMVAR

Definition at line 94 of file EnergyMinimization.h.

double* EnergyMinimization::blc [private]
 

Lower bound on the constraint.

Size: NUMCON

Definition at line 64 of file EnergyMinimization.h.

double* EnergyMinimization::blx [private]
 

Lower bound on the variable.

Size: NUMVAR

Definition at line 99 of file EnergyMinimization.h.

double* EnergyMinimization::buc [private]
 

Upper bound on the constraint.

Size: NUMCON

Definition at line 69 of file EnergyMinimization.h.

double* EnergyMinimization::bux [private]
 

Upper bound on the variable.

Size: NUMVAR

Definition at line 105 of file EnergyMinimization.h.

double* EnergyMinimization::c [private]
 

Linear minimization part.

Size: NUMVAR

Definition at line 110 of file EnergyMinimization.h.

Mesh* EnergyMinimization::mesh [private]
 

Definition at line 26 of file EnergyMinimization.h.

int EnergyMinimization::NUMANZ [private]
 

Number of nonzeros i A.

Definition at line 54 of file EnergyMinimization.h.

int EnergyMinimization::NUMCON [private]
 

Number of constraints.

Definition at line 48 of file EnergyMinimization.h.

int EnergyMinimization::NUMVAR [private]
 

Number of variables.

Definition at line 51 of file EnergyMinimization.h.

int* EnergyMinimization::ptrb [private]
 

For represenations of sparse constraint matrix: beginning of the row.

Size: NUMVAR

Definition at line 74 of file EnergyMinimization.h.

int* EnergyMinimization::ptre [private]
 

For represenations of sparse constraint matrix: ending of the row.

Size: NUMVAR

Definition at line 79 of file EnergyMinimization.h.

int* EnergyMinimization::sub [private]
 

For represenations of sparse constraint matrix: subscipts for nonzero values in the row.

Size: NUMANZ

Definition at line 84 of file EnergyMinimization.h.

MSKtask_t EnergyMinimization::task [private]
 

Definition at line 28 of file EnergyMinimization.h.

double* EnergyMinimization::val [private]
 

For represenations of sparse constraint matrix: values in the matrix.

Size: NUMANZ

Definition at line 89 of file EnergyMinimization.h.

double* EnergyMinimization::xx [private]
 

Variable that we optimize for - radii of circum centers of triangles.

Size: NUMVAR

Definition at line 115 of file EnergyMinimization.h.


The documentation for this class was generated from the following files:
Generated on Sat Jun 3 13:33:42 2006 for CirclePatterns by  doxygen 1.4.5