Finished adding javadocs to learn

This commit is contained in:
leandrohw 2017-07-09 17:16:59 -06:00
parent 57cf9a485d
commit 9d272ec8ab
19 changed files with 715 additions and 141 deletions

View file

@ -208,6 +208,9 @@ public final class HierarchicalODERKSimulator extends HierarchicalSimulation {
} catch (NumberIsTooSmallException e) {
setCurrentTime(nextEndTime);
}
catch (MaxCountExceededException e) {
setCurrentTime(nextEndTime);
}
} else {
setCurrentTime(nextEndTime);
}
@ -338,6 +341,12 @@ public final class HierarchicalODERKSimulator extends HierarchicalSimulation {
@Override
public void computeDerivatives(double t, double[] y, double[] yDot)
throws MaxCountExceededException, DimensionMismatchException {
if(Double.isNaN(t))
{
throw new MaxCountExceededException(t);
}
setCurrentTime(t);
vectorWrapper.setValues(y);
computeAssignmentRules();

View file

@ -0,0 +1,160 @@
package edu.utah.ece.async.ibiosim.learn;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.stream.XMLStreamException;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.Parameter;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBMLReader;
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.BioSimException;
import edu.utah.ece.async.ibiosim.learn.genenet.Experiments;
import edu.utah.ece.async.ibiosim.learn.genenet.Run;
import edu.utah.ece.async.ibiosim.learn.genenet.SpeciesCollection;
import edu.utah.ece.async.ibiosim.learn.parameterestimator.ParameterEstimator;
/**
* Command line method for running the learn jar file.
* <p>
* Requirements:
* <p>
* inputfile: full path to the input SBML file.
* <p>
* directory: directory where the experimental data is located.
* <p>
* Options:
* <p>
* -e: when specified, the program will run parameter estimation.
* -l: when specified, parameter estimation will use the estimate the value of the paramaters in the list.
*
* @author Leandro Watanabe
* @author Tramy Nguyen
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
*/
public class Learn {
private static void usage() {
System.err.println("Description:");
System.err.println("\tExecutes bayesian methods for structural learning using GeneNet or parameter estimation using SRES.");
System.err.println("Usage:");
System.err.println("\tjava -jar iBioSim-learn-3.0.0-SNAPSHOT-jar-with-dependencies.jar [options] <Input File> <Project Directory>");
System.err.println("Required:");
System.err.println("\t<Input File> the input SBML file.");
System.err.println("\t<Project Directory> the directory where the experimental data is located.");
System.err.println("Options:");
System.err.println("\t-e to execute parameter estimation.");
System.err.println("\t-l to specify the list of parameters to estimate. If not specified, all parameters are estimated.");
System.err.println("\t to use it, specify the parameters separated by commas (e.g. p1,p2,p3).");
System.exit(1);
}
public static void main(String[] args) {
if(args.length < 2)
{
usage();
}
boolean runParameterEstimation = false;
List<String> listOfParameters = null;
String filename = args[args.length-2];
String directory = args[args.length-1];
for(int i = 0; i < args.length-2; i++)
{
if(args[i].startsWith("-"))
{
if(args[i].length() == 2)
{
if(args[i].charAt(1) == 'e')
{
runParameterEstimation = true;
}
else if(args[i].charAt(1) == 'l')
{
if(i+1 < args.length-2)
{
listOfParameters = new ArrayList<String>();
String unparsedList = args[i+1];
String[] parsedList = unparsedList.split(",");
for(String param : parsedList)
{
listOfParameters.add(param);
}
}
else
{
usage();
}
}
}
else
{
usage();
}
}
}
if(runParameterEstimation)
{
try {
if(listOfParameters == null)
{
listOfParameters = new ArrayList<String>();
SBMLDocument doc = SBMLReader.read(new File(filename));
Model model = doc.getModel();
for(Parameter param : model.getListOfParameters())
{
listOfParameters.add(param.getId());
}
}
SpeciesCollection S = new SpeciesCollection();
Experiments E = new Experiments();
Run.init(filename, S);
Run.loadExperiments(directory, S, E);
SBMLDocument newDocument = ParameterEstimator.estimate(filename, directory, listOfParameters, E, S);
if (newDocument != null)
{
Model model = newDocument.getModel();
for (String parameterId : listOfParameters)
{
Parameter parameter = model.getParameter(parameterId);
if(parameter != null)
{
System.out.println(parameterId + " = " + parameter.getValue());
}
else
{
System.out.println(parameterId + " = NA");
}
}
}
} catch (IOException e) {
System.err.println("The program encoutered IO problems.");
} catch (XMLStreamException e) {
System.err.println("The program could not parse the input SBML file.");
} catch (BioSimException e) {
System.err.println("Error: " + e.getMessage());
}
}
else
{
try {
Run.run(filename, directory);
} catch (BioSimException e) {
System.err.println("Error: " + e.getMessage());
}
}
}
}

View file

@ -19,7 +19,8 @@ import java.util.List;
import java.util.Map;
/**
*
* A connection object is used to represent a potential influence from a set of influencers
* to a particular species.
*
* @author Leandro Watanabe
* @author Chris Myers
@ -34,7 +35,7 @@ public class Connection
private List<String> parents;
private Map<String, Type> parentToType;
public enum Type
private enum Type
{
ACTIVATOR("activator"), REPRESSOR("repressor"), UNKNOWN("unknown");
@ -47,6 +48,16 @@ public class Connection
}
/**
* This object class is used to store the connections and their types among different species.
* Several connections may exist between two species. A score is used to distinguish the likelihood
* of each connection.
*
* @param child - the influenced species.
* @param score - the likelihood of this connection existence.
* @param type - what kind of connection this is.
* @param parent - the influencing species.
*/
public Connection(String child, double score, String type, String parent)
{
this.child = child;
@ -56,7 +67,15 @@ public class Connection
this.parentToType = new HashMap<String, Type>();
this.parentToType.put(parent, getType(type));
}
/**
* This object class is used to store the connections and their types among different species.
* This is used when a child species is influenced by many species.
*
* @param child - the influenced species.
* @param score - the likelihood of this connection existence.
* @param connections - the different connections that influence a certain species.
*/
public Connection(String child, double score, List<Connection> connections)
{
this.child = child;
@ -76,6 +95,14 @@ public class Connection
}
/**
* This object class is used to store the connections and their types among different species.
* This is used when a child species is influenced by many species.
*
* @param child - the influenced species.
* @param score - the likelihood of this connection existence.
* @param connections - the different connections that influence a certain species.
*/
public Connection(String child, double score, Connection... connections)
{
this.child = child;
@ -95,7 +122,8 @@ public class Connection
}
public Type getType(String type)
private Type getType(String type)
{
type = type.toLowerCase();
@ -113,21 +141,42 @@ public class Connection
}
}
/**
* Gets the score of this connection.
*
* @return the score value.
*/
public double getScore()
{
return score;
}
/**
* Get the parent species (the one that is influencing) of this connection.
*
* @return the parent species.
*/
public List<String> getParents()
{
return parents;
}
/**
* Get the child species (the one that is influenced by) of this connection.
*
* @return the child species.
*/
public String getChild()
{
return child;
}
/**
* Get the type of influence by the parent.
*
* @param parent - the parent species.
* @return the type of influence.
*/
public String getParentType(String parent)
{
if (parentToType.containsKey(parent))
@ -140,6 +189,12 @@ public class Connection
}
}
/**
* Check if this connection has all parents from a given list.
*
* @param parents - the list of parents that needs to be checked whether they participate in this connection.
* @return true if connection has all the parents from given list. False otherwise.
*/
public boolean equalParents(List<String> parents)
{
for (String parent : parents)
@ -159,6 +214,11 @@ public class Connection
return "Connection [score=" + score + ", child=" + child + ", parents=" + getParents() + "]";
}
/**
* Returns a string corresponding to the parent species of this connection.
*
* @return the list of parents as a string.
*/
public String getParentString()
{
String list = "";

View file

@ -19,7 +19,9 @@ import java.util.List;
import java.util.Map;
/**
*
* An encodings object is used to represent how a set of data is represented in the
* learning procedure. The data is discretized to facilitate the identification of
* potential influencing connections between species.
*
* @author Leandro Watanabe
* @author Chris Myers
@ -33,6 +35,9 @@ public class Encodings
private Map<Integer, double[]> discreteSpecies;
private List<List<List<Integer>>> levelAssignments;
/**
* Creates an Encodings object with default number of bins.
*/
public Encodings()
{
numBins = 3;
@ -40,6 +45,11 @@ public class Encodings
levelAssignments = new ArrayList<List<List<Integer>>>();
}
/**
* Creates an Encodings object with a specified number of bins.
*
* @param bin - number of bins.
*/
public Encodings(int bin)
{
numBins = bin;
@ -47,11 +57,25 @@ public class Encodings
levelAssignments = new ArrayList<List<List<Integer>>>();
}
/**
* Add the values of a particular species.
*
* @param col - integer corresponding to the column entry of a species in the data table.
* @param values - the values of the species.
*/
public void addDiscreteSpecies(int col, double[] values)
{
discreteSpecies.put(col, values);
}
/**
* Associate a value to a certain entry in the data table from a specified experiment.
*
* @param experiment - experiment index from which the value is coming from
* @param row - the row in the data table to insert a value.
* @param col - the column in the data table to insert a value.
* @param data - the value that is inserted to the data table.
*/
public void addLevelAssignment(int experiment, int row, int col, double data)
{
while (levelAssignments.size() < experiment + 1)
@ -69,6 +93,13 @@ public class Encodings
levelAssignments.get(experiment).get(row).set(col, getLevelAssignment(col, data));
}
/**
* The discretized value of a certain value.
*
* @param col - the column entry of the data table.
* @param data - the value to be transformed.
* @return the discretized value of data.
*/
public int getLevelAssignment(int col, double data)
{
double[] discrete = discreteSpecies.get(col);
@ -84,16 +115,29 @@ public class Encodings
return numBins - 1;
}
/**
* Get the level assignments.
*
* @return the level assignments.
*/
public List<List<List<Integer>>> getLevelAssignments()
{
return levelAssignments;
}
/**
* Get the size of the level assignments.
*
* @return size of level assignments.
*/
public int size()
{
return levelAssignments.size();
}
/**
* Print the level assignments for each experiment.
*/
public void print()
{
for (int i = 0; i < levelAssignments.size(); i++)

View file

@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List;
/**
*
* This object holds the experimental data that is used for learning.
*
* @author Leandro Watanabe
* @author Chris Myers
@ -29,11 +29,22 @@ public class Experiments
private List<List<List<Double>>> experiments;
/**
* Creates an Experiments object.
*/
public Experiments()
{
experiments = new ArrayList<List<List<Double>>>();
}
/**
* Adds a value to a certain experiment table.
*
* @param experiment - the experiment that the data is coming from.
* @param row - the row that data is being inserted to.
* @param col - the column that the data is being inserted to.
* @param data - the value that is being inserted.
*/
public void addExperiment(int experiment, int row, int col, double data)
{
while (experiments.size() < experiment + 1)
@ -51,21 +62,46 @@ public class Experiments
experiments.get(experiment).get(row).set(col, data);
}
/**
* Get a data point from the data table of a given experiment.
*
* @param experiment - the experiment you are getting data from.
* @param row - the row of the data you want.
* @param col - the column of the data you want.
* @return the value at the specified index of the given experiment.
*/
public double getDataPoint(int experiment, int row, int col)
{
return experiments.get(experiment).get(row).get(col);
}
/**
* Remove mutations. Not supported yet.
*
* @param s - a species that you want to remove mutations from.
* @return a new Experiments object without mutations.
*/
public Experiments removeMutations(String s)
{
//TODO
return this;
}
/**
* Get number of experiments.
*
* @return the number of experiments.
*/
public int getNumOfExperiments()
{
return experiments.size();
}
/**
* Get the experiments.
*
* @return a set of data tables, one for each experiment.
*/
public List<List<List<Double>>> getExperiments()
{
return experiments;

View file

@ -28,11 +28,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import edu.utah.ece.async.ibiosim.dataModels.biomodel.parser.BioModel;
import edu.utah.ece.async.ibiosim.dataModels.util.GlobalConstants;
import edu.utah.ece.async.ibiosim.dataModels.util.exceptions.BioSimException;
/**
*
* The class that encapsulates the GeneNet algorithm.
*
* @author Leandro Watanabe
* @author Chris Myers
@ -44,28 +45,34 @@ public class Learn
private int bins;
/**
* Creates a learn object.
*
* @param bins - the number of bins that specifies level assignments.
*/
public Learn(int bins)
{
this.bins = bins;
}
public void learnBaselineNetwork(SpeciesCollection S, Experiments E, NetCon C)
{
for (int i = 0; i < S.size(); i++)
{
String s_0 = S.getInterestingSpecies(i);
for (int j = 0; j < S.size(); j++)
{
String s_1 = S.getInterestingSpecies(j);
if (!s_0.equals(s_1))
{
addParent(s_0, s_1, E, S, C);
}
}
}
}
// private void learnBaselineNetwork(SpeciesCollection S, Experiments E, NetCon C)
// {
// for (int i = 0; i < S.size(); i++)
// {
// String s_0 = S.getInterestingSpecies(i);
//
// for (int j = 0; j < S.size(); j++)
// {
// String s_1 = S.getInterestingSpecies(j);
//
// if (!s_0.equals(s_1))
// {
// addParent(s_0, s_1, E, S, C);
// }
// }
// }
// }
private void addParent(String parent, String child, Experiments E, SpeciesCollection S, NetCon C)
{
@ -148,6 +155,18 @@ public class Learn
}
}
/**
* This is the core of the GeneNet procedure. It will learn the connectivity of the
* species from experimental data.
*
* @param S - collection of species.
* @param E - collection of experiments.
* @param C - network connectivity of the model.
* @param T - threshold values.
* @param L - the encodings of the data.
*
* @throws BioSimException - when there is malformed data input.
*/
public void learnNetwork(SpeciesCollection S, Experiments E, NetCon C, Thresholds T, Encodings L) throws BioSimException
{
EncodeExpts(S, E, C, T, L);
@ -629,6 +648,16 @@ public class Learn
}
/**
* Builds a dot file corresponding to the connectivity of the species.
*
* @param filename - name of the dot file being produced.
* @param directory - where the dot file will be saved.
* @param collection - the species that will be in the dot file.
* @param network - the connections among species.
*
* @throws BioSimException - when an error occurs.
*/
public void getDotFile(String filename, String directory, SpeciesCollection collection, NetCon network) throws BioSimException
{
Map<String, String> speciesToNode;
@ -703,8 +732,7 @@ public class Learn
{
throw new BioSimException("Failed to close outputstream", "Error in Learning");
}
}
}
}

View file

@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
/**
*
* A NetCon object holds the connections of the species.
*
* @author Leandro Watanabe
* @author Chris Myers
@ -31,16 +31,33 @@ public class NetCon
private Map<String, List<Connection>> connections;
/**
* Creates a NetCon object.
*/
public NetCon()
{
connections = new HashMap<String, List<Connection>>();
}
/**
* Checks if a species contains an edge.
*
* @param s - Any arbitrary species in the design.
* @return true if the given species has an edge. False otherwise.
*/
public boolean containEdge(String s)
{
return false;
}
/**
* Adds a connection.
*
* @param child - the influenced species.
* @param type - the type of influence.
* @param score - the score of the connection.
* @param parent - the influencing species.
*/
public void addConnection(String child, String type, double score, String parent)
{
if (!connections.containsKey(child))
@ -50,6 +67,12 @@ public class NetCon
connections.get(child).add(new Connection(child, score, type, parent));
}
/**
* Add a connection for a given species.
*
* @param child - the species that has the connection.
* @param connection - the connection object containing information about the connection.
*/
public void addConnection(String child, Connection connection)
{
if (!connections.containsKey(child))
@ -59,6 +82,13 @@ public class NetCon
connections.get(child).add(connection);
}
/**
* Adds a collection of connections with a given score to a particular species.
*
* @param child - the species that has the connection.
* @param score - the score of the connection.
* @param collections - a list of connections.
*/
public void addConnection(String child, double score, Connection... collections)
{
if (!connections.containsKey(child))
@ -68,6 +98,12 @@ public class NetCon
connections.get(child).add(new Connection(child, score, collections));
}
/**
* Remove a particular connection from a species.
*
* @param child - the species that has the connection to be removed.
* @param connection - the connection to be removed.
*/
public void removeConnection(String child, Connection connection)
{
if (connections.containsKey(child))
@ -76,6 +112,12 @@ public class NetCon
}
}
/**
* Removes connection of a species from a list of influencers.
*
* @param child - the species that has the connection to be removed.
* @param parents - the list of species that should have the connections removed from given species.
*/
public void removeConnectionByParent(String child, List<String> parents)
{
List<Connection> listOfConnections = connections.get(child);
@ -90,6 +132,12 @@ public class NetCon
}
/**
* Removes connection by index.
*
* @param child - the species that has the connection to be removed.
* @param index - the index of connection to be removed.
*/
public void removeConnection(String child, int index)
{
if (connections.containsKey(child))
@ -98,11 +146,22 @@ public class NetCon
}
}
/**
* Get connections of given species.
*
* @param s - a specified species.
* @return a list of connections of the given species.
*/
public List<Connection> getListOfConnections(String s)
{
return connections.get(s);
}
/**
* Returns a map of all existing connections.
*
* @return a map of all existing connections.
*/
public Map<String, List<Connection>> getConnections()
{
return connections;

View file

@ -44,7 +44,7 @@ public class Run
public static boolean run(String filename, String directory) throws BioSimException
{
experiment = 0;
SpeciesCollection S = new SpeciesCollection();
Experiments E = new Experiments();
Encodings L = new Encodings();
@ -67,7 +67,7 @@ public class Run
public static void loadExperiments(String directory, SpeciesCollection S, Experiments E) throws BioSimException
{
File path = new File(directory);
experiment = 0;
for (File file : path.listFiles())
{
String name = file.getAbsolutePath();

View file

@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
/**
*
* A SpeciesCollection object contains the interesting species that participate in the genetic circuit.
*
* @author Leandro Watanabe
* @author Chris Myers
@ -33,6 +33,9 @@ public class SpeciesCollection
private Map<Integer, String> columnSpecies;
private Map<String, Integer> speciesColumn;
/**
* Creates a species collection object.
*/
public SpeciesCollection()
{
interestingSpecies = new ArrayList<String>();
@ -40,37 +43,76 @@ public class SpeciesCollection
speciesColumn = new HashMap<String, Integer>();
}
/**
* Associates species with a particular column in the data table.
*
* @param id - id of the species.
* @param index - index of the species in the data table.
*/
public void addSpecies(String id, int index)
{
speciesColumn.put(id, index);
columnSpecies.put(index, id);
}
/**
* Adds interesting species to the collection.
*
* @param id- id of the species.
*/
public void addInterestingSpecies(String id)
{
interestingSpecies.add(id);
}
/**
* Get column index of a given species
*
* @param species - id of species.
* @return the column index.
*/
public int getColumn(String species)
{
return speciesColumn.get(species);
}
/**
* Gets species id from index.
*
* @param index - index of species in data table.
* @return the id of the species.
*/
public String getInterestingSpecies(int index)
{
return interestingSpecies.get(index);
}
/**
* Returns the number of species in the collection.
*
* @return the number of species in the collection.
*/
public int size()
{
return interestingSpecies.size();
}
/**
* Returns all interesting species.
*
* @return list of interesting species.
*/
public List<String> getInterestingSpecies()
{
return interestingSpecies;
}
/**
* Checks if species is in the collection already.
*
* @param species - id of species.
* @return true if species is present. False otherwise.
*/
public boolean containsSpeciesData(String species)
{
return speciesColumn.containsKey(species);

View file

@ -14,7 +14,7 @@
package edu.utah.ece.async.ibiosim.learn.genenet;
/**
*
* A Thresholds object is used to compute the type of interaction of a connection.
*
* @author Leandro Watanabe
* @author Chris Myers
@ -26,6 +26,9 @@ public class Thresholds
private double Ta, Tr, Tv, Tt;
/**
* Creates a Thresholds object using default values.
*/
public Thresholds()
{
Ta = 1.15;
@ -34,6 +37,13 @@ public class Thresholds
Tt = 0.025;
}
/**
* Creates a Thresholds object using custom values.
*
* @param Ta - activation threshold.
* @param Tr - repression threshold.
* @param Tv - no influence threshold.
*/
public Thresholds(double Ta, double Tr, double Tv)
{
this.Ta = Ta;
@ -42,36 +52,71 @@ public class Thresholds
this.Tt = 0.025;
}
/**
* Returns the threshold value of activation.
*
* @return activation threshold value.
*/
public double getTa()
{
return Ta;
}
/**
* Returns the threshold value of repression.
*
* @return repression threshold value.
*/
public double getTr()
{
return Tr;
}
/**
* Returns the threshold value with no influence.
*
* @return threshold for no influence.
*/
public double getTv()
{
return Tv;
}
/**
* Set activation threshold.
*
* @param Ta - value of threshold.
*/
public void setTa(double Ta)
{
this.Ta = Ta;
}
/**
* Set repression threshold.
*
* @param Tr - value of threshold.
*/
public void setTr(double Tr)
{
this.Tr = Tr;
}
/**
* Set threshold for no influence.
*
* @param Tv - value of threshold.
*/
public void setTv(double Tv)
{
this.Tv = Tv;
}
/**
* Returns relaxation threshold.
*
* @return relaxation threshold.
*/
public double getTt()
{
return Tt;

View file

@ -37,8 +37,6 @@ import edu.utah.ece.async.ibiosim.learn.parameterestimator.methods.sres.SRES;
/**
*
*
* @author
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
@ -58,6 +56,22 @@ public class ParameterEstimator
static ArrayList<String> interestingSpecies = new ArrayList<String>();
static String quantityType = "amount";
/**
* This function is used to execute parameter estimation from a given SBML file. The input model serves
* as a template and the existing parameters in the model will set the bounds to which parameter estimation will use.
* <p>
* In addition, the SBML file is used for simulation when estimating the values of the parameters.
*
* @param SBMLFileName: the input SBML file
* @param root: the directory where the experimental data is located
* @param parameterList: the list of parameters that needs to have the value estimated.
* @param experiments: data object that holds the experimental data.
* @param speciesCollection: data object that holds the species in the model.
* @return A new SBMLDocument containing the new parameter values.
* @throws IOException - when a file cannot be read or written.
* @throws XMLStreamException - when an SBML file cannot be parsed.
* @throws BioSimException - when simulation encounters a problem.
*/
public static SBMLDocument estimate(String SBMLFileName, String root, List<String> parameterList, Experiments experiments, SpeciesCollection speciesCollection) throws IOException, XMLStreamException, BioSimException
{
@ -82,7 +96,6 @@ public class ParameterEstimator
ObjectiveSqureError TP = new ObjectiveSqureError(sim, experiments, parameterList, speciesCollection, M1, 0.1);
SRES sres = new SRES(TP, EMS);
// System.out.println("test");
SRES.Solution solution = sres.run(200).getBestSolution();
// TODO: report results: take average of error

View file

@ -14,9 +14,8 @@
package edu.utah.ece.async.ibiosim.learn.parameterestimator.methods;
/**
*
*
* @author
* Interface for parameter estimation methods.
*
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%

View file

@ -13,8 +13,15 @@
*******************************************************************************/
package edu.utah.ece.async.ibiosim.learn.parameterestimator.methods.pedi;
/**
*
* @author Chris Myers
* @version $Rev$
*/
public class GeneProduct
{
/*
private double mRNADegradationConstant;
private double translationConstant;
private double proteinDegradationConstant;
@ -35,12 +42,6 @@ public class GeneProduct
return 0;
}
/**
* RNA degradation constants for each gene. NaN if the constant is unknown,
* value if the constant is known.
*
* @return
*/
public double getmRNADegradationConstant()
{
return mRNADegradationConstant;
@ -130,4 +131,5 @@ public class GeneProduct
{
this.proteinLevel = proteinLevel;
}
*/
}

View file

@ -13,9 +13,14 @@
*******************************************************************************/
package edu.utah.ece.async.ibiosim.learn.parameterestimator.methods.pedi;
/**
*
* @author Chris Myers
* @version $Rev$
*/
public interface PEDIBridge
{
public double[][] simulate(GeneProduct[] genes, double startTime, double endTime, double printInterval);
//public double[][] simulate(GeneProduct[] genes, double startTime, double endTime, double printInterval);
}

View file

@ -15,8 +15,6 @@ package edu.utah.ece.async.ibiosim.learn.parameterestimator.methods.sres;
/**
*
*
* @author
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
@ -24,23 +22,6 @@ package edu.utah.ece.async.ibiosim.learn.parameterestimator.methods.sres;
public class EvolutionMethodSetting
{
/*
* * @param verbose if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
*
* @param lambda solution set size
*
* @param mu number of top-ranking solutions selected to produce new
* solution set at each generation
*
* @param expectedConvergenceRate expected convergence rate
*
* @param numberOfSweeps number of times stochastic ranking bubble-sort is
* applied to solution set
*
* @param rankingPenalizationFactor constraint breaking penalization factor,
* should be in { [0, 1]};
*/
boolean verbose;
int lambda;
int mu;
@ -51,41 +32,116 @@ public class EvolutionMethodSetting
double tauDash;
int numberOfgenerations;
/**
* Creates evolution method setting using default values.
*/
public EvolutionMethodSetting()
{
this(true, 200, 30, 1.0, 200, 1000, 0.45);
}
/**
* Creates evolution method setting.
*
* @param verbose - if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
*/
public EvolutionMethodSetting(boolean verbose)
{
this(verbose, 200, 30, 1.0, 200, 1000, 0.45);
}
/**
* Creates evolution method setting.
*
* @param verbose - if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
* @param lambda - solution set size.
*/
public EvolutionMethodSetting(boolean verbose, int lambda)
{
this(verbose, lambda, 30, 1.0, 200, 1000, 0.45);
}
/**
* Creates evolution method setting.
*
* @param verbose- if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
* @param lambda - solution set size.
* @param mu - number of top-ranking solutions selected to produce new
* solution set at each generation.
*/
public EvolutionMethodSetting(boolean verbose, int lambda, int mu)
{
this(verbose, lambda, mu, 1.0, 200, 1000, 0.45);
}
/**
* Creates evolution method setting.
*
* @param verbose- if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
* @param lambda - solution set size.
* @param mu - number of top-ranking solutions selected to produce new
* solution set at each generation.
* @param expectedConvergenceRate expected convergence rate
*/
public EvolutionMethodSetting(boolean verbose, int lambda, int mu, double expectedConvergenceRate)
{
this(verbose, lambda, mu, expectedConvergenceRate, 200, 1000, 0.45);
}
/**
* Creates evolution method setting.
*
* @param verbose- if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
* @param lambda - solution set size.
* @param mu - number of top-ranking solutions selected to produce new
* solution set at each generation.
* @param expectedConvergenceRate expected convergence rate
* @param numberOfSweeps number of times stochastic ranking bubble-sort is
* applied to solution set
*/
public EvolutionMethodSetting(boolean verbose, int lambda, int mu, double expectedConvergenceRate, int numberOfSweeps)
{
this(verbose, lambda, mu, expectedConvergenceRate, numberOfSweeps, 1000, 0.45);
}
/**
* Creates evolution method setting.
*
* @param verbose- if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
* @param lambda - solution set size.
* @param mu - number of top-ranking solutions selected to produce new
* solution set at each generation.
* @param expectedConvergenceRate - expected convergence rate
* @param numberOfSweeps - number of times stochastic ranking bubble-sort is
* applied to solution set
* @param numberofgenerations - number of generations
*/
public EvolutionMethodSetting(boolean verbose, int lambda, int mu, double expectedConvergenceRate, int numberOfSweeps, int numberofgenerations)
{
this(verbose, lambda, mu, expectedConvergenceRate, numberOfSweeps, numberofgenerations, 0.45);
}
/**
* Creates evolution method setting.
*
* @param verbose- if set to true, will print the number of generations
* passed and other statistics to {@code stderr}
* @param lambda - solution set size.
* @param mu - number of top-ranking solutions selected to produce new
* solution set at each generation.
* @param expectedConvergenceRate - expected convergence rate
* @param numberOfSweeps - number of times stochastic ranking bubble-sort is
* applied to solution set
* @param numberofgenerations - number of generations
* @param rankingPenalizationFactor - constraint breaking penalization factor,
* should be in { [0, 1]};
*/
public EvolutionMethodSetting(boolean verbose, int lambda, int mu, double expectedConvergenceRate, int numberOfSweeps, int numberofgenerations, double rankingPenalizationFactor)
{
this.verbose = verbose;
@ -101,36 +157,71 @@ public class EvolutionMethodSetting
this.expectedConvergenceRate = expectedConvergenceRate;
}
/**
* Returns verbose flag.
*
* @return verbose flag.
*/
public boolean getverbose()
{
return verbose;
}
/**
* Returns lambda.
*
* @return lambda.
*/
public int getlamda()
{
return lambda;
}
/**
* Returns mu.
*
* @return mu.
*/
public int getmu()
{
return mu;
}
/**
* Returns the expected convergence rate.
*
* @return the expected convergence rate.
*/
public double getexpectedConvergenceRate()
{
return expectedConvergenceRate;
}
/**
* Returns the number of sweeps.
*
* @return the number of sweeps.
*/
public int getnumberOfSweeps()
{
return numberOfSweeps;
}
/**
* Returns ranking penalization factor.
*
* @return - ranking penalization factor.
*/
public double getrankingPenalizationFactor()
{
return rankingPenalizationFactor;
}
/**
* Returns the number of generations.
*
* @return number of generations.
*/
public double getnumberOfgenerations()
{
return numberOfgenerations;

View file

@ -23,8 +23,6 @@ import java.util.List;
/**
*
*
* @author
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
@ -41,6 +39,17 @@ public class Modelsettings
boolean verbose;
int nums;
/**
* Creates a model settings object.
*
* @param ic - time course.
* @param ngenes - number of genes.
* @param sp - starting point.
* @param ep - ending point.
* @param lowerbounds - lower bounds of parameter search space.
* @param upperbounds - upper bounds of parameter search space.
* @param verbose - verbose option.
*/
public Modelsettings(List<Double> ic, int ngenes, int sp, int ep, double[] lowerbounds, double[] upperbounds, boolean verbose)
{
@ -53,57 +62,4 @@ public class Modelsettings
this.verbose = verbose;
}
public double[][] loaddata(String filename)
{
// StringBuffer sb=new StringBuffer();
String tempstr = null;
int lines = 0;
int rows = 0;
double[][] tmps = new double[100][100];
try
{
// String path="/Users/mfan/Documents/program/data/model1.txt";
String path = new String(filename);
File file = new File(path);
if (!file.exists())
{
throw new FileNotFoundException();
}
// BufferedReader br=new BufferedReader(new FileReader(file));
// while((tempstr=br.readLine())!=null)
// sb.append(tempstr);
FileInputStream fis = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
while ((tempstr = br.readLine()) != null)
{
String s[] = tempstr.split(" ");
// System.out.println(s.length);
for (int i = 0; i < s.length; ++i)
{
tmps[lines][i] = Double.parseDouble(s[i]);
}
lines = lines + 1;
rows = s.length;
}
br.close();
// double rows=tmps[0].length;
}
catch (IOException ex)
{
System.out.println(ex.getStackTrace());
}
double[][] data = new double[lines][rows];
for (int i = 0; i < lines; i++)
{
for (int j = 0; j < rows; j++)
{
data[i][j] = tmps[i][j];
}
}
return data;
// return sb.toString();
}
}

View file

@ -19,10 +19,9 @@ import java.util.Arrays;
* A class representing a real multivariate objective function and constraints
* that are subject to optimization. The objective functionmethod is left for
* the user to specify. Arbitrary value range is allowed for objective function.
* Constraints are provided as { constraint_value <= 0} inequalities, the
* Constraints are provided as constraint &le; 0 inequalities, the
* computation of array should be implemented by user.
*
* @author
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
@ -34,18 +33,17 @@ public abstract class Objective
private final double[] mutationRates;
private final boolean maximizationProblem;
/**
* Generates an objective function instance and specifies the feature
* (argument) space.
*
* @param featureLowerBounds
* lower bounds of feature space
* @param featureUpperBounds
* upper bounds of feature space
* @param maximizationProblem
* if set to true, the objective function is subject to
* maximization task, minimization will be performed otherwise
*/
/**
* Generates an objective function instance and specifies the feature
* (argument) space.
*
* @param Ms contains information about:
* featureUpperBounds
* upper bounds of feature space and lower bounds of feature space
* maximizationProblem
* if set to true, the objective function is subject to
* maximization task, minimization will be performed otherwise
*/
public Objective(Modelsettings Ms)
{
@ -125,7 +123,6 @@ public abstract class Objective
* @param features
* an array of objective function features
* @return objective function evaluation result
* @see com.antigenomics.jsres.Objective.Result
*/
public abstract Result evaluate(double[] features);
@ -183,7 +180,7 @@ public abstract class Objective
/**
* Creates a new instance of objective function evaluation result.
* Constraints should be re-written as {constraint_value <= 0}
* Constraints should be re-written as {constraint_value &le; 0}
* inequalities and {@code constraint_value} array should be provided.
*
* @param value

View file

@ -23,9 +23,8 @@ import edu.utah.ece.async.ibiosim.learn.genenet.Experiments;
import edu.utah.ece.async.ibiosim.learn.genenet.SpeciesCollection;
/**
*
*
* @author
* ObjectiveSqureError
*
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
@ -55,6 +54,15 @@ public class ObjectiveSqureError extends Objective
* allowedViolatedConstraintsCount, 1e-6, 1e-3); }
*/
/**
* Creates an ObjectiveSqureError object.
* @param sim - simulators
* @param experiments - experimental data
* @param parameterList - list of parameters to estimate
* @param speciesCollection - list of interesting species
* @param Ms - model settings
* @param valueAtSolution - true value
*/
public ObjectiveSqureError(HierarchicalSimulation sim, Experiments experiments, List<String> parameterList, SpeciesCollection speciesCollection, Modelsettings Ms, double valueAtSolution)
{
super(Ms);
@ -73,6 +81,15 @@ public class ObjectiveSqureError extends Objective
this.sim = sim;
}
/**
* Creates an ObjectiveSqureError object.
*
* @param Ms - model settings
* @param valueAtSolution - true value
* @param allowedViolatedConstraintsCount - constraint count
* @param absolutePrecision - absolute error
* @param relativePrecision - relative error
*/
public ObjectiveSqureError(Modelsettings Ms, double valueAtSolution, int allowedViolatedConstraintsCount, double absolutePrecision, double relativePrecision)
{
super(Ms);
@ -123,6 +140,12 @@ public class ObjectiveSqureError extends Objective
return new Result(sum);
}
/**
* Checked if solution is solved.
*
* @param solution - solution object
* @return true is solution is solved. False otherwise.
*/
public boolean isSolved(SRES.Solution solution)
{
Objective.Result result = solution.getObjectiveResult();

View file

@ -22,11 +22,8 @@ import edu.utah.ece.async.ibiosim.learn.parameterestimator.methods.AbstractEstim
* A class that implements Stochastic Ranking Evolutionary Strategy (SRES), an
* evolutionary algorithm for constrained optimization of real multivariate
* objective functions. User should provide an objective function instance
* inherited from abstract {@link com.antigenomics.jsres.Objective} class. The
* algorithm is executed via { #run} method. Objective function evaluation is
* optimized by implementing .
* inherited. The algorithm is executed via { #run} method.
*
* @author
* @author Chris Myers
* @author <a href="http://www.async.ece.utah.edu/ibiosim#Credits"> iBioSim Contributors </a>
* @version %I%
@ -103,6 +100,14 @@ public final class SRES implements AbstractEstimator
* this.rankingPenalizationFactor = rankingPenalizationFactor; }
*/
/**
* Creates an instance of SRES algorithm for a given objective function.
*
* @param objective
* objective function instance
* @param EMS
* the evolution method setting instance
*/
public SRES(Objective objective, EvolutionMethodSetting EMS)
{
this.objective = objective;