EnergyMinimization.cpp File Reference


Detailed Description

Definitions for the EnergyMinimization class.

Author:
Liliya Kharevych
Date:
March 2006

Definition in file EnergyMinimization.cpp.

#include "EnergyMinimization.h"
#include "CirclePattern.h"
#include "mosek.h"
#include "util.h"
#include <fstream>
#include <iomanip>

Go to the source code of this file.

Functions

static int MSKAPI nlspar (void *nlhandle, int *numgrdobjnz, int *grdobjsub, int i, int *convali, int *grdconinz, int *grdconisub, int yo, int numycnz, int ycsub[], int maxnumhesnz, int *numhesnz, int *hessubi, int *hessubj)
 Purpose: Provide MOSEK with information about nonlinear problem structure and sparsity.
static int MSKAPI nleval (void *nlhandle, double *xx, double yo, double *yc, double *objval, int *numgrdobjnz, int *grdobjsub, double *grdobjval, int numi, int *subi, double *conval, int *grdconptrb, int *grdconptre, int *grdconsub, double *grdconval, double *grdlag, int maxnumhesnz, int *numhesnz, int *hessubi, int *hessubj, double *hesval)
 Purpose: Evalute the nonlinear function, gradient and Hessian and return the requested information to MOSEK.


Function Documentation

static int MSKAPI nleval void *  nlhandle,
double *  xx,
double  yo,
double *  yc,
double *  objval,
int *  numgrdobjnz,
int *  grdobjsub,
double *  grdobjval,
int  numi,
int *  subi,
double *  conval,
int *  grdconptrb,
int *  grdconptre,
int *  grdconsub,
double *  grdconval,
double *  grdlag,
int  maxnumhesnz,
int *  numhesnz,
int *  hessubi,
int *  hessubj,
double *  hesval
[static]
 

Purpose: Evalute the nonlinear function, gradient and Hessian and return the requested information to MOSEK.

f(x) is computed and stored in objval[0].

Compute and store the gradient of the f.

Compute and store the Hessian

Definition at line 71 of file EnergyMinimization.cpp.

00078 {
00079    Mesh * mesh = (Mesh *)nlhandle;
00080    int NumInteriorEdges = mesh->numEdges() - mesh->numBoundary();
00081 
00082    if ( objval) {
00083       objval[0] = CirclePattern::evaluateEnergy(mesh, xx);   
00084    }
00085    if ( numgrdobjnz ) {
00086       numgrdobjnz[0] = mesh->numFaces();                     
00087       for (int k = 0; k < mesh->numFaces(); k++) 
00088           grdobjsub[k] = k;
00089       CirclePattern::computeGradient(mesh, xx, grdobjval);
00090    }
00091    if ( conval )
00092       for(int k=0; k<numi; ++k)
00093           conval[k] = 0.0;
00094 
00095    if ( grdlag ) 
00096       CirclePattern::computeGradient(mesh, xx, grdlag);
00097 
00098    if ( maxnumhesnz ) {
00099       if ( yo==0.0 ) 
00100           numhesnz[0] = 0;
00101       else {                                                
00103           check_error (maxnumhesnz < (NumInteriorEdges + mesh->numFaces()), 
00104              "Not enough space was allocated for hessian.");
00105           numhesnz[0] = NumInteriorEdges + mesh->numFaces();
00106 
00107           if ( hessubi && hessubj && hesval ) {
00108              CirclePattern::buildSparsityForHessian(mesh, hessubi, hessubj);
00109              CirclePattern::computeHessian(mesh, xx, hesval);
00110           }
00111       }
00112    }
00113    return ( MSK_RES_OK );
00114 } /* nleval */

static int MSKAPI nlspar void *  nlhandle,
int *  numgrdobjnz,
int *  grdobjsub,
int  i,
int *  convali,
int *  grdconinz,
int *  grdconisub,
int  yo,
int  numycnz,
int  ycsub[],
int  maxnumhesnz,
int *  numhesnz,
int *  hessubi,
int *  hessubj
[static]
 

Purpose: Provide MOSEK with information about nonlinear problem structure and sparsity.

Number of variables in the objective is equal to number of faces in the mesh.

Store indicies of nonlinear variable in the objective.

Hessian has non-zeros on the diagonal and for each interior edge.

Definition at line 24 of file EnergyMinimization.cpp.

00028 {
00029 
00030    Mesh * mesh = (Mesh *)nlhandle;
00031    Mesh::HalfEdgeIterator hIter = mesh->halfEdgeIterator();
00032    int NumInteriorEdges = mesh->numEdges() - mesh->numBoundary();
00033 
00034    if ( numgrdobjnz ) {
00036       numgrdobjnz[0] = mesh->numFaces();
00037 
00038       if ( grdobjsub ) {
00040           for (int i = 0; i <  mesh->numFaces(); i++)
00041              grdobjsub[i] = i;
00042       }
00043    }
00044 
00045    if ( convali )
00046       convali[0] = 0;    /* Zero because no nonlinear expression in the constraint. */
00047 
00048    if ( grdconinz )
00049       grdconinz[0] = 0;  /* Zero because no nonlinear expression in the constraint. */
00050 
00051    if ( numhesnz ) {
00052       if (yo)
00053           numhesnz[0] = NumInteriorEdges + mesh->numFaces();   
00054       else
00055           numhesnz[0] = 0;
00056    }
00057 
00058    if ( maxnumhesnz ) {
00059       check_error (maxnumhesnz < (NumInteriorEdges + mesh->numFaces()), "Not enough space was allocated for hessian.");
00060       if (yo) {
00061           if  (hessubi && hessubj) 
00062              CirclePattern::buildSparsityForHessian(mesh, hessubi, hessubj);
00063       }
00064    }
00065    return ( MSK_RES_OK );
00066 } /* nlspar */


Generated on Sat Jun 3 13:33:42 2006 for CirclePatterns by  doxygen 1.4.5