JavaView® v2.00.008

jvx.numeric
Class PnEnergyMinimizer

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jvx.numeric.PnEnergyMinimizer
All Implemented Interfaces:
java.lang.Cloneable, PsUpdateIf, java.lang.Runnable, java.io.Serializable

public class PnEnergyMinimizer
extends PsObject
implements java.lang.Runnable

Main class to vary a surface to minimize a given energy functional. Minimization runs in a separate thread. For Dirichlet and Area minimization support for hessian and eigenvalues included.

Version:
04.01.01, 1.50 revised (kp) Domain geometry may be missing.
08.11.00, 2.10 revised (kp) Replace formatting with PuString rather than Fmt.
21.07.99, 2.00 revised (kp)
00.00.98, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
Serialized Form

Field Summary
static int AREA
           
static int CONFORMAL
           
static int DIRICHLET
           
protected  boolean m_bHessianIsL2Normalized
          Flag whether hessian matrix is normalized with inverse of L2 matrix.
protected  boolean m_bRunning
          Flag used to indicate that thread should stop.
protected  boolean m_bUpdateDomain
          Flag whether domain is updated after each CG-minization loop.
protected  boolean m_bUpdateNormals
          Flag whether surface normals are updated after each minimization loop.
protected  double m_cgEps
          Accuracy criteria used to terminate CG iterations.
protected  PnConjugateGradient m_cgMethod
          Conjugate Gradient Method.
protected  PdVector m_coord
          Coordinate vector.
protected  int m_currLoop
          Current loops in CG algorithm, used in infoPanel.
protected  PgElementSet m_domain
          Optional domain surface used for minimizing energies related to maps between surfaces.
protected  PnEnergy m_energy
          Function computing some energy, its gradient and hessian.
protected  PdVector m_eValue
          Vector with eigenvalues.
protected  PdVector[] m_eVector
          Array with eigenvectors.
protected  int[] m_evSortInd
          Index vector listing eigenvalues by size.
protected  double m_finalEnergy
          Energy after minimization, used in infoPanel.
protected  PdMatrix m_hessian
          Hessian matrix.
protected  double m_initialEnergy
          Initial energy, used in infoPanel.
protected  int m_numIterations
          Number of used iterations in last CG algorithm, used in infoPanel.
protected  int m_numLoops
          Number of loops, i.e. number of calls to CG algorithm, used in infoPanel.
protected  PgElementSet m_surface
          Surface which will be modified.
protected  java.lang.Thread m_thread
          Thread running during minimization.
protected  PgVectorField m_vf
          Vector field for display of gradient and eigenvectors.
static int SPRING
           
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS
 
Constructor Summary
PnEnergyMinimizer()
           
 
Method Summary
 void computeEigenvectors()
           
 void enableUpdateDomain(boolean flag)
          Flag whether domain is updated after each CG-minization loop.
 PgElementSet getDomain()
           
 PnEnergy getEnergy()
          Get current energy.
 PgElementSet getSurface()
           
 void init()
          If instance has missing name then assign default name 'object_NUMBER' where number is the total number of already created instances.
 boolean isRunning()
          Check whether energy minimizer is currently running a minimization process.
 double minimize()
          Minimize energy by invoking conjugate gradient method in a loop.
 void printEigenvalues()
           
 void printEigenvectors()
           
 void printGradient()
           
 void printHessian()
           
 void run()
          Do energy minimization until m_numLoops are done or until a call of stop().
 void setEnergy(PnEnergy energy)
          Set new energy and clear all vector fields.
 void setNumLoops(int numLoops)
          Set number of calls of conjugate gradient method to be performed during each call to PnEnergyMinimizer#minimize().
 boolean setSurface(PgElementSet domain, PgElementSet surface)
          Set references to domain and image surface.
 void showEigenvector(int ind)
           
 void showGradient()
           
 void showNone()
           
 void start()
          Start energy minimization in separate thread.
 void step()
          Move vertices in negative gradient direction as certain amount.
 void stop()
          Stop energy minimization in separate thread.
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DIRICHLET

public static final int DIRICHLET

AREA

public static final int AREA

CONFORMAL

public static final int CONFORMAL

SPRING

public static final int SPRING

m_domain

protected PgElementSet m_domain
Optional domain surface used for minimizing energies related to maps between surfaces.

m_surface

protected PgElementSet m_surface
Surface which will be modified. Target geometry of maps.

m_vf

protected PgVectorField m_vf
Vector field for display of gradient and eigenvectors. Field is reset to null whenever the number of vertices changes.

m_hessian

protected PdMatrix m_hessian
Hessian matrix.

m_bUpdateNormals

protected boolean m_bUpdateNormals
Flag whether surface normals are updated after each minimization loop.

m_bUpdateDomain

protected boolean m_bUpdateDomain
Flag whether domain is updated after each CG-minization loop. When iteratively computing harmonic maps copy image surface into domain after minimization to update domain metric. Main use is inside Pinkall/Polthier algorithm on computing minimal surfaces by iterating harmonic maps.

m_coord

protected PdVector m_coord
Coordinate vector.

m_cgMethod

protected PnConjugateGradient m_cgMethod
Conjugate Gradient Method.

m_energy

protected PnEnergy m_energy
Function computing some energy, its gradient and hessian.

m_numLoops

protected int m_numLoops
Number of loops, i.e. number of calls to CG algorithm, used in infoPanel.

m_currLoop

protected int m_currLoop
Current loops in CG algorithm, used in infoPanel.

m_cgEps

protected double m_cgEps
Accuracy criteria used to terminate CG iterations.

m_initialEnergy

protected double m_initialEnergy
Initial energy, used in infoPanel.

m_finalEnergy

protected double m_finalEnergy
Energy after minimization, used in infoPanel.

m_numIterations

protected int m_numIterations
Number of used iterations in last CG algorithm, used in infoPanel.

m_thread

protected java.lang.Thread m_thread
Thread running during minimization.

m_eVector

protected PdVector[] m_eVector
Array with eigenvectors.

m_eValue

protected PdVector m_eValue
Vector with eigenvalues.

m_evSortInd

protected int[] m_evSortInd
Index vector listing eigenvalues by size.

m_bHessianIsL2Normalized

protected boolean m_bHessianIsL2Normalized
Flag whether hessian matrix is normalized with inverse of L2 matrix.

m_bRunning

protected boolean m_bRunning
Flag used to indicate that thread should stop.
Constructor Detail

PnEnergyMinimizer

public PnEnergyMinimizer()
Method Detail

init

public void init()
Description copied from class: PsObject
If instance has missing name then assign default name 'object_NUMBER' where number is the total number of already created instances.
Overrides:
init in class PsObject

update

public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.
Overrides:
update in class PsObject
Following copied from class: jv.object.PsObject
See Also:
PsObject.setParent(PsUpdateIf), PsObject.getFather(), PsObject.addUpdateListener(PsUpdateIf)

getEnergy

public PnEnergy getEnergy()
Get current energy.

setEnergy

public void setEnergy(PnEnergy energy)
Set new energy and clear all vector fields. Domain argument maybe null.

enableUpdateDomain

public void enableUpdateDomain(boolean flag)
Flag whether domain is updated after each CG-minization loop. When iteratively computing harmonic maps copy image surface into domain after minimization to update domain metric. Main use is inside Pinkall/Polthier algorithm on computing minimal surfaces by iterating harmonic maps.

getDomain

public PgElementSet getDomain()

getSurface

public PgElementSet getSurface()

setSurface

public boolean setSurface(PgElementSet domain,
                          PgElementSet surface)
Set references to domain and image surface. Image surface is usually being minimized while domain surface is often used when minimizing energy of maps between surfaces. Dimension of vertices of domain and surface may be different, e.g., domain may have 2-dimensional and surface may have 1-dimensional vertices.

Remark: If the geometries are changed outside this energy minimizer, the user must call setSurface() again to update the energy minimizer. Otherwise, further minimization calls will use the old geometry information.


setNumLoops

public void setNumLoops(int numLoops)
Set number of calls of conjugate gradient method to be performed during each call to PnEnergyMinimizer#minimize().

This number of loops is independent of the number of iterations used in each single invocation of the CG-method, which depends on the requested accurracy PnEnergyMinimizer#m_cgEps.

See Also:
minimize()

minimize

public double minimize()
Minimize energy by invoking conjugate gradient method in a loop. A separate thread is started which calls in each step a conjugate gradient method. The number of loops may be set using #setNumLoops(int).
See Also:
setNumLoops(int)

step

public void step()
Move vertices in negative gradient direction as certain amount. Amount is gradient*h with h=0.01*numLoops.

printGradient

public void printGradient()

showNone

public void showNone()

showGradient

public void showGradient()

printHessian

public void printHessian()

computeEigenvectors

public void computeEigenvectors()

printEigenvalues

public void printEigenvalues()

printEigenvectors

public void printEigenvectors()

showEigenvector

public void showEigenvector(int ind)

isRunning

public boolean isRunning()
Check whether energy minimizer is currently running a minimization process.

start

public void start()
Start energy minimization in separate thread.

stop

public void stop()
Stop energy minimization in separate thread.

run

public void run()
Do energy minimization until m_numLoops are done or until a call of stop().
Specified by:
run in interface java.lang.Runnable

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.