public class DataSet extends Object implements Identifiable<DataSetException>, Storable
| Modifier and Type | Class and Description |
|---|---|
static class |
DataSet.Field
This is set of fields for input/output to XML and JSON format
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearAllData()
Clears Observations, VariableObservations and CalculationResults data from this DataSet.
|
void |
clearObservation(Node node)
Clears an observation from a Node if it exists.
|
void |
clearObservations()
Clears all non-variable observations from this DataSet for all Networks and Nodes
|
void |
clearVariableObservation(Node node,
String variableName)
Clears the VariableObservation of the provided name in this DataSet for the provided Node.
|
void |
clearVariableObservations()
Clears all VariableObservations from this DataSet for all Networks and Nodes.
|
void |
clearVariableObservations(Node node)
Clears all VariableObservations from this DataSet for the provided Node.
|
protected static DataSet |
createDataSet(Model model,
org.json.JSONObject jsonDataSet)
Creates a DataSet for the Model from JSON data.
|
protected static DataSet |
createDataSet(Model model,
String id)
Factory method to create a DataSet and add it to the given Model.
|
CalculationResult |
getCalculationResult(Node node)
Returns the CalculationResult for the given Node.
|
List<CalculationResult> |
getCalculationResults()
Gets all CalculationResults for all Nodes for this DataSet.
|
Map<Node,CalculationResult> |
getCalculationResults(Network network)
Maps nodes to calculation results in the given network in this data set.
|
protected int |
getDataSetIndex()
Gets the index of corresponding logic scenario in the underlying logical model structure
|
String |
getId()
Gets the ID of this DataSet.
|
uk.co.agena.minerva.model.scenario.Scenario |
getLogicScenario()
Deprecated.
Will be made module-restricted in the future.
|
Model |
getModel()
Returns the Model that this DataSet belongs to.
|
Observation |
getObservation(Node node)
Returns a view of the observation for the given node if there is one.
|
Set<Observation> |
getObservations()
Returns all observations in this DataSet for all Networks and Nodes.
|
Set<Observation> |
getObservationsAndVariables()
Returns all Observations and VariableObservations in this DataSet for all Networks and Nodes.
|
Set<Observation> |
getObservationsAndVariables(Node node)
Returns all Observations and VariableObservations in this DataSet for the provided Node.
|
VariableObservation |
getVariableObservation(Node node,
String variableName)
Returns a view of the VariableObservation for the provided Node and variable name if there is one.
|
Set<VariableObservation> |
getVariableObservations()
Returns all VariableObservations in this DataSet for all Networks and Nodes.
|
Set<VariableObservation> |
getVariableObservations(Node node)
Returns a view of VariableObservations for the provided Node.
|
boolean |
hasObservation(Node node)
Checks whether the Node has an observation set.
|
boolean |
hasVariableObservation(Node node,
String variableName)
Checks whether the provided variable in the provided node is observed in this DataSet.
|
void |
loadCalculationResult(org.json.JSONObject jsonResult)
Loads calculation result data for this DataSet from a given JSON and creates corresponding objects in the underlying logic.
|
void |
setId(String id)
Changes the ID of this Network to the provided ID, if the new ID is not already taken.
|
protected void |
setLogicScenario(uk.co.agena.minerva.model.scenario.Scenario logicScenario)
Links this Network to an underlying Minerva Network object.
|
void |
setObservation(org.json.JSONObject jsonObservation)
Sets observations according to the given JSON.
|
void |
setObservation(Node node,
Object value)
Sets a hard observation for a Node.
|
protected void |
setObservationConstant(Node node,
String constantName,
double value)
Sets a node constant observation for a Node.
|
void |
setObservationHard(Node node,
double value)
Sets a hard real observation for a Node.
|
void |
setObservationHard(Node node,
int value)
Sets a hard integer observation for a Node.
|
void |
setObservationHard(Node node,
String state)
Sets a hard observation for a Node.
|
void |
setObservationSoft(Node node,
Map<String,Double> weights)
Sets a soft observation for the node, assigning a given weights to given states.
|
void |
setObservationSoft(Node node,
String[] states,
Double[] weights)
Sets a soft observation for the node, assigning a given weights to given states.
|
void |
setVariableObservation(Node node,
String variableName,
double value)
Sets a value for the provided variable in the provided Node in this DataSet to override its default value
|
org.json.JSONObject |
toJson()
Creates a JSONObject representation of this DataSet
|
protected static DataSet createDataSet(Model model, String id)
model - Model to create and add DataSet toid - unique ID/name of the DataSetprotected static DataSet createDataSet(Model model, org.json.JSONObject jsonDataSet) throws ModelException, DataSetException
model - the model to create a data set injsonDataSet - the JSON dataModelException - if a DataSet with this ID already existsDataSetException - if failed to load observations or results datapublic final uk.co.agena.minerva.model.scenario.Scenario getLogicScenario()
protected void setLogicScenario(uk.co.agena.minerva.model.scenario.Scenario logicScenario)
logicScenario - the logical scenariopublic final Model getModel()
public final String getId()
getId in interface Identifiable<DataSetException>public final void setId(String id) throws DataSetException
setId in interface Identifiable<DataSetException>id - the new IDDataSetException - if fails to change IDpublic void setObservationHard(Node node, int value) throws DataSetException
node - the Node to set observation forvalue - the observation valueDataSetException - if any:
public void setObservationHard(Node node, double value) throws DataSetException
node - the Node to set observation forvalue - the observation valueDataSetException - if any:
public void setObservationHard(Node node, String state) throws DataSetException
node - the Node to set observation forstate - observed stateDataSetException - if any:
protected void setObservationConstant(Node node, String constantName, double value) throws DataSetException
node - the Node to set observation forconstantName - node constant to observevalue - the constant valueDataSetException - if any:
public void setObservation(Node node, Object value) throws DataSetException
node - the Node to set observation forvalue - the observation valueDataSetException - if any of the following applies:
public void setObservationSoft(Node node, String[] states, Double[] weights) throws DataSetException
node - the Node to set observation forstates - Array of statesweights - Array of weightsDataSetException - if any of the following applies:
public void setObservationSoft(Node node, Map<String,Double> weights) throws DataSetException
node - the Node to set observation forweights - the map of states and weightsDataSetException - if any of the following applies:
public void setObservation(org.json.JSONObject jsonObservation)
throws DataSetException,
org.json.JSONException
jsonObservation - JSON with observationsDataSetException - if any of the following applies:
org.json.JSONException - if missing or invalid attributespublic boolean hasVariableObservation(Node node, String variableName)
node - the Node to checkvariableName - the name of the variablepublic void setVariableObservation(Node node, String variableName, double value) throws DataSetException
node - the Node with the variablevariableName - the name of the variablevalue - the value of the variable to setDataSetException - if setting the value of the variable failedpublic Set<VariableObservation> getVariableObservations(Node node)
node - the observed Nodepublic VariableObservation getVariableObservation(Node node, String variableName)
node - the observed NodevariableName - the variable namepublic Set<VariableObservation> getVariableObservations()
public void clearVariableObservation(Node node, String variableName)
node - the Node with the variablevariableName - the name of the variablepublic void clearVariableObservations(Node node)
node - Node to clear VariableObservations frompublic void clearVariableObservations()
public void clearAllData()
public void clearObservation(Node node)
node - the Node to clear the Observation frompublic void clearObservations()
public boolean hasObservation(Node node)
node - the Node to check for observationspublic Set<Observation> getObservationsAndVariables(Node node)
node - the observed Nodepublic Set<Observation> getObservationsAndVariables()
public Set<Observation> getObservations()
public Observation getObservation(Node node)
node - the observed Nodepublic CalculationResult getCalculationResult(Node node)
node - the Node for which CalculationResult should be returnedpublic List<CalculationResult> getCalculationResults()
public Map<Node,CalculationResult> getCalculationResults(Network network)
network - Network to get calculation results forpublic void loadCalculationResult(org.json.JSONObject jsonResult)
throws DataSetException,
org.json.JSONException
jsonResult - CalculationResult in JSON formatDataSetException - if any:
org.json.JSONException - if JSON data is invalidprotected int getDataSetIndex()
Copyright © 2020. All rights reserved.