org.omegahat.Numerics.Optimizers
Class ModelPointDatabase

java.lang.Object
  |
  +--org.omegahat.Numerics.Optimizers.ModelPointDatabase
All Implemented Interfaces:
Activable, Database, ModelPoint, ModelPointNumericInt

public class ModelPointDatabase
extends java.lang.Object
implements Database, ModelPointNumericInt

Class to allow ModelPoint objects to associate parameters with names.

Objects from this class work just like normal ModelPoint objects, and are normally instantiated with a ModelPoint and a String[] array of corresponding names.


Field Summary
protected  java.lang.String[] names
           
protected  ModelPointNumericInt point
           
protected  ObjectDatabase table
           
 
Fields inherited from interface org.omegahat.Environment.Databases.Database
ALL, ASSIGN, ATTACH, DETACH, NULL_ENTRY, READ, READ_WRITE, REMOVE
 
Fields inherited from interface org.omegahat.Environment.Databases.Activable
ACTIVE, INACTIVE
 
Constructor Summary
ModelPointDatabase(ModelPointNumericInt point)
           
 
Method Summary
 boolean assign(java.lang.String name, java.lang.Object obj)
          assigns obj to the database under name.
 boolean attach(DatabaseCustomer e)
           
 void clear()
          remove all the objects from the database.
 ModelPoint copy()
          Copy the object.
 void copyData(ModelPoint theta)
          copy in the data from theta.
 boolean detach(DatabaseCustomer e)
           
 void evaluate()
          Evaluate the model at the current point, using the model property to define the objective.
 boolean exists(java.lang.String name)
          does the object exist in the database?
 java.lang.Object get(java.lang.String name)
          returns the object in the database assigned under the name.
 NumericArray getGradient()
           
 NumericMatrix getHessian()
           
 ModelObjective getModel()
           
 java.lang.String getName()
           
 java.lang.String[] getNames()
          Accessor for names field
 NumericArray getParameters()
           
 ModelPointNumericInt getPoint()
          Accessor for point field
 int getState()
           
 ObjectDatabase getTable()
          Accessor for table field
 double getValue()
           
 boolean isEvaluated()
           
 java.lang.String[] objects()
          the array of object names.
 java.lang.Object remove(java.lang.String name)
          remove the object from the database
 boolean setEvaluated(boolean value)
           
 NumericArray setGradient(NumericArray value)
           
 NumericMatrix setHessian(NumericMatrix value)
           
 ModelObjective setModel(ModelObjective value)
           
 java.lang.String setName(java.lang.String name)
           
 java.lang.String[] setNames(java.lang.String[] value)
          Set the names field to value.
 NumericArray setParameters(NumericArray value)
           
 ModelPointNumericInt setPoint(ModelPointNumericInt value)
          Accessor for setting point field
 int setState(int state)
           
 ObjectDatabase setTable(ObjectDatabase value)
          Accessor for setting table field
 double setValue(double value)
           
 void show()
           
 void show(java.lang.String header)
           
 int size()
          what is the size (in bytes?) of the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

point

protected ModelPointNumericInt point

names

protected java.lang.String[] names

table

protected ObjectDatabase table
Constructor Detail

ModelPointDatabase

public ModelPointDatabase(ModelPointNumericInt point)
Method Detail

getPoint

public ModelPointNumericInt getPoint()
Accessor for point field

setPoint

public ModelPointNumericInt setPoint(ModelPointNumericInt value)
Accessor for setting point field

getNames

public java.lang.String[] getNames()
Accessor for names field
Specified by:
getNames in interface ModelPointNumericInt

setNames

public java.lang.String[] setNames(java.lang.String[] value)
Set the names field to value.

Also creates and sets the corresponding hash-table field for accessing the elements by name.

Specified by:
setNames in interface ModelPointNumericInt

getTable

public ObjectDatabase getTable()
Accessor for table field

setTable

public ObjectDatabase setTable(ObjectDatabase value)
Accessor for setting table field

assign

public boolean assign(java.lang.String name,
                      java.lang.Object obj)
Description copied from interface: Database
assigns obj to the database under name.
Specified by:
assign in interface Database
Following copied from interface: org.omegahat.Environment.Databases.Database
Parameters:
obj - any object, including null
name - a string (preferably non-empty) to locate the object in the database.

attach

public boolean attach(DatabaseCustomer e)
Specified by:
attach in interface Database

clear

public void clear()
Description copied from interface: Database
remove all the objects from the database.
Specified by:
clear in interface Database

detach

public boolean detach(DatabaseCustomer e)
Specified by:
detach in interface Database

exists

public boolean exists(java.lang.String name)
Description copied from interface: Database
does the object exist in the database?
Specified by:
exists in interface Database

get

public java.lang.Object get(java.lang.String name)
Description copied from interface: Database
returns the object in the database assigned under the name. or null if none.
Specified by:
get in interface Database

getName

public java.lang.String getName()
Specified by:
getName in interface Database

objects

public java.lang.String[] objects()
Description copied from interface: Database
the array of object names.
Specified by:
objects in interface Database

remove

public java.lang.Object remove(java.lang.String name)
Description copied from interface: Database
remove the object from the database
Specified by:
remove in interface Database
Following copied from interface: org.omegahat.Environment.Databases.Database
Parameters:
name - any string, matching the one used in a previous assignment.

setName

public java.lang.String setName(java.lang.String name)
Specified by:
setName in interface Database

size

public int size()
Description copied from interface: Database
what is the size (in bytes?) of the database.
Specified by:
size in interface Database

setState

public int setState(int state)
Specified by:
setState in interface Activable

getState

public int getState()
Specified by:
getState in interface Activable

evaluate

public void evaluate()
Description copied from interface: ModelPointNumericInt
Evaluate the model at the current point, using the model property to define the objective. Store the resulting value and optional gradient and hessian in this object and set the evaluated property to true.
Specified by:
evaluate in interface ModelPointNumericInt

getValue

public double getValue()
Specified by:
getValue in interface ModelPointNumericInt

setValue

public double setValue(double value)
Specified by:
setValue in interface ModelPointNumericInt

getGradient

public NumericArray getGradient()
Specified by:
getGradient in interface ModelPointNumericInt

setGradient

public NumericArray setGradient(NumericArray value)
Specified by:
setGradient in interface ModelPointNumericInt

getHessian

public NumericMatrix getHessian()
Specified by:
getHessian in interface ModelPointNumericInt

setHessian

public NumericMatrix setHessian(NumericMatrix value)
Specified by:
setHessian in interface ModelPointNumericInt

getParameters

public NumericArray getParameters()
Specified by:
getParameters in interface ModelPointNumericInt

setParameters

public NumericArray setParameters(NumericArray value)
Specified by:
setParameters in interface ModelPointNumericInt

isEvaluated

public boolean isEvaluated()
Specified by:
isEvaluated in interface ModelPointNumericInt

setEvaluated

public boolean setEvaluated(boolean value)
Specified by:
setEvaluated in interface ModelPointNumericInt

show

public void show(java.lang.String header)
Specified by:
show in interface ModelPoint

show

public void show()
Specified by:
show in interface ModelPoint

copy

public ModelPoint copy()
Copy the object. The contained model point is copied; a new database is created with the same contents as the current one. (The objects other than those in the original named elements of the model point may not be copyable, and aren't copied.)
Specified by:
copy in interface ModelPoint

copyData

public void copyData(ModelPoint theta)
Description copied from interface: ModelPoint
copy in the data from theta.

The parameters will be those in theta, as will the value, gradient, and hessian (either of the latter two can be null). If allocate is true, the fields will be newly allocated; otherwise, data will be copied into them if they match in structure the corresponding fields in theta.

Specified by:
copyData in interface ModelPoint

getModel

public ModelObjective getModel()
Specified by:
getModel in interface ModelPointNumericInt

setModel

public ModelObjective setModel(ModelObjective value)
Specified by:
setModel in interface ModelPointNumericInt