public class Parameters extends java.lang.Object implements java.lang.Iterable<Parameter>, java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
Parameters.ParameterException
Exception related to the parameters
|
| Constructor and Description |
|---|
Parameters()
Creates an empty set of parameters
|
Parameters(java.util.List<Parameter> params)
Creates a set of parameters containing the given parameters
|
| Modifier and Type | Method and Description |
|---|---|
void |
addParameter(Parameter p)
Add a parameter
|
void |
addParameters(Parameters pp)
Adds the parameters from another set of parameters
|
Parameters |
clone() |
static Parameters |
fromFile(java.io.File f)
Reads parameters from a file.
|
Parameter |
getParam(java.lang.String name)
Gets the parameter with the given name
|
double |
getValue(java.lang.String name)
Gets the value of a parameter
|
java.util.HashMap<java.lang.String,java.lang.Double> |
getValues()
Gets a map from parameter name to the value of that parameter
|
boolean |
hasParam(java.lang.String name)
Checks whether there is a parameter with the given name
|
java.util.Iterator<Parameter> |
iterator() |
int |
numberEstimate()
Gets the number of parameters to be estimated
|
void |
setValue(Parameter p,
double v)
Sets the value of a parameter
|
void |
toFile(java.io.File f)
Writes the parameter values to a file.
|
void |
toFile(java.io.File f,
double like)
Writes the parameter values to a file and writes a line labeled likelihood
and which gives the likelihood given as input.
|
java.lang.String |
toString() |
java.lang.String |
toString(boolean fixed)
Returns a string representation of the parameters
|
public Parameters()
public Parameters(java.util.List<Parameter> params) throws Parameters.ParameterException
params - A list of parametersParameters.ParameterException - If there is already a
parameter with the same name as one to be added.public Parameters clone()
clone in class java.lang.Objectpublic final void addParameter(Parameter p) throws Parameters.ParameterException
p - The parameterParameters.ParameterException - If there is already a
parameter with that name.public void addParameters(Parameters pp) throws Parameters.ParameterException
pp - The other set of parametersParameters.ParameterException - If there is already a
parameter with the same name as one to be added.public void setValue(Parameter p, double v) throws Parameters.ParameterException
p - The parameterv - The valueParameters.ParameterException - Thrown if an attempt
is made to set the parameter to a value outside it's boundspublic double getValue(java.lang.String name)
throws Parameters.ParameterException
name - The parameters nameParameters.ParameterException - Thrown if there is no
parameter with that namepublic Parameter getParam(java.lang.String name) throws Parameters.ParameterException
name - The name of the parameterParameters.ParameterException - Thrown if there is no
parameter with that namepublic final boolean hasParam(java.lang.String name)
name - The name of the parameterpublic java.util.HashMap<java.lang.String,java.lang.Double> getValues()
public int numberEstimate()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(boolean fixed)
fixed - Whether to include fixed parameters in the outputpublic java.util.Iterator<Parameter> iterator()
iterator in interface java.lang.Iterable<Parameter>public void toFile(java.io.File f)
throws OutputException
Parameter.fromString(java.lang.String)f - File to write the parameters toOutputException - Thrown if an error occurs writing the filepublic void toFile(java.io.File f,
double like)
throws OutputException
Parameter.fromString(java.lang.String)f - File to write the parameters tolike - The likelihood valueOutputException - Thrown if an error occurs writing the filepublic static Parameters fromFile(java.io.File f) throws InputException, Parameters.ParameterException
Parameter.fromString(java.lang.String).f - The input fileInputException - If there is an input errorParameters.ParameterException - If the file contains
two parameters with the same name.