Class ReasoningResult
- java.lang.Object
-
- net.ssehub.easy.reasoning.core.reasoner.ReasoningResult
-
- Direct Known Subclasses:
EvaluationResult,ValueCreationResult
public class ReasoningResult extends java.lang.ObjectResult of (one) reasoning step.- Author:
- El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IDecisionVariable>affectedprivate booleanhasConflictprivate booleanhasTimeoutprivate java.util.Map<IMeasurementKey,java.lang.Number>measuresprivate java.util.List<Message>messagesprivate booleanwasStopped
-
Constructor Summary
Constructors Constructor Description ReasoningResult()General constructor for new ReasoningResults.ReasoningResult(java.lang.String reasonerName)Constructor for a result denoting the the chosen constructor is not able to handle the called operation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAffected(IDecisionVariable var)Adds a variable affected by reasoning.voidaddMessage(Message message)Adds a new Message to the current result, e.IDecisionVariablegetAffectedVariable(int index)Returns the affected variable specified byindex.intgetAffectedVariablesCount()Return the number of affected variables.java.lang.NumbergetMeasure(IMeasurementKey key)Returns the measure for a specifickey.MessagegetMessage(int index)Returns the message specified byindex.intgetMessageCount()Returns the number of messages related to this reasoning result.booleanhasConflict()Denotes whether this reasoning result represents an error/conflict.booleanhasInfo()Checks whether this result contains anyStatus.INFOmessages, indicating that the configuration was changed.booleanhasTimeout()Returns whether reasoning was stopped due to a timeout.voidlogInformation(Project prj, ReasonerConfiguration rConfig)Logs reasoning summary based onprj, the measures and the messages.voidlogInformation(Project prj, ReasonerConfiguration.IAdditionalInformationLogger infoLogger, boolean withMessages)Logs reasoning summary based onprj, the measures and the messages.voidlogInformation(Project prj, ReasonerConfiguration rConfig, boolean withMessages)Logs reasoning summary based onprj, the measures and the messages.java.util.Set<IMeasurementKey>measurementKeys()Returns all measurement keys.booleanprovidesInformationOnAffectedVariables()Returns whether information on affected variables is provided.booleanreasoningUnsupported()Returns whether the called reasoning step is supported by this reasoner.voidsetMeasure(IMeasurementKey key, java.lang.Number value)Sets a reasoner-specific measure.voidsetStopped(boolean wasStopped)Changes whether reasoning was stopped due to a user request.voidsetTimeout(boolean hasTimeout)Changes whether reasoning was stopped due to a timeout.booleanwasStopped()Returns whether reasoning was stopped due to a user request.
-
-
-
Field Detail
-
affected
private java.util.List<IDecisionVariable> affected
-
messages
private java.util.List<Message> messages
-
hasConflict
private boolean hasConflict
-
hasTimeout
private boolean hasTimeout
-
wasStopped
private boolean wasStopped
-
measures
private java.util.Map<IMeasurementKey,java.lang.Number> measures
-
-
Constructor Detail
-
ReasoningResult
public ReasoningResult()
General constructor for new ReasoningResults.
-
ReasoningResult
public ReasoningResult(java.lang.String reasonerName)
Constructor for a result denoting the the chosen constructor is not able to handle the called operation.- Parameters:
reasonerName- The name of the reasoner, which was called.
-
-
Method Detail
-
addAffected
public void addAffected(IDecisionVariable var)
Adds a variable affected by reasoning. A reasoner may use this method to communicate affected variables and, thus, support further language mechanisms, such as runtime instantiation.- Parameters:
var- the affected variable
-
addMessage
public void addMessage(Message message)
Adds a new Message to the current result, e. g. an Error or Warning- Parameters:
message- The new message which should be added to this result.
-
setTimeout
public void setTimeout(boolean hasTimeout)
Changes whether reasoning was stopped due to a timeout.- Parameters:
hasTimeout-truefor timeout,falseelse
-
setStopped
public void setStopped(boolean wasStopped)
Changes whether reasoning was stopped due to a user request.- Parameters:
wasStopped-truefor stopped,falseelse
-
hasTimeout
public boolean hasTimeout()
Returns whether reasoning was stopped due to a timeout.- Returns:
truefor timeout,falseelse
-
wasStopped
public boolean wasStopped()
Returns whether reasoning was stopped due to a user request.- Returns:
truefor stopped,falseelse
-
hasConflict
public boolean hasConflict()
Denotes whether this reasoning result represents an error/conflict.- Returns:
- true if the reasoning result represents an error, otherwise false.
- See Also:
hasTimeout
-
hasInfo
public boolean hasInfo()
Checks whether this result contains anyStatus.INFOmessages, indicating that the configuration was changed.- Returns:
- true if this result contains at least one
Status.INFOmessage, false otherwise.
-
reasoningUnsupported
public boolean reasoningUnsupported()
Returns whether the called reasoning step is supported by this reasoner.- Returns:
- true if the reasoning was not supported, otherwise false.
-
getMessageCount
public int getMessageCount()
Returns the number of messages related to this reasoning result.- Returns:
- the number of messages in this result
-
getMessage
public Message getMessage(int index)
Returns the message specified byindex.- Parameters:
index- a 0-based index specifying the message to be returned- Returns:
- the message
- Throws:
java.lang.IndexOutOfBoundsException- ifindex<0 || index>=getMessageCount()
-
providesInformationOnAffectedVariables
public boolean providesInformationOnAffectedVariables()
Returns whether information on affected variables is provided.- Returns:
trueif information of affected variables is provided,falseelse (thengetAffectedVariablesCount()will always be0).
-
getAffectedVariablesCount
public int getAffectedVariablesCount()
Return the number of affected variables.- Returns:
- the number of affected variables
-
getAffectedVariable
public IDecisionVariable getAffectedVariable(int index)
Returns the affected variable specified byindex.- Parameters:
index- a 0-based index specifying the variable to be returned- Returns:
- the affected variable
- Throws:
java.lang.IndexOutOfBoundsException- ifindex<0 || index>=getAffectedVariablesCount()
-
setMeasure
public void setMeasure(IMeasurementKey key, java.lang.Number value)
Sets a reasoner-specific measure.- Parameters:
key- the key (null is ignored)value- the measure (may be null)
-
getMeasure
public java.lang.Number getMeasure(IMeasurementKey key)
Returns the measure for a specifickey.- Parameters:
key- the key (null is ignored)- Returns:
- the measure (may be null)
-
measurementKeys
public java.util.Set<IMeasurementKey> measurementKeys()
Returns all measurement keys.- Returns:
- the keys, may be null if there are none
-
logInformation
public void logInformation(Project prj, ReasonerConfiguration rConfig)
Logs reasoning summary based onprj, the measures and the messages. Reasoners shall not produce output except for debugging stuff. If explicit output is required, call this method after reasoning. Logs with reasoner messages by default.- Parameters:
prj- the project representing the modelrConfig- the configuration containing the information logger
-
logInformation
public void logInformation(Project prj, ReasonerConfiguration rConfig, boolean withMessages)
Logs reasoning summary based onprj, the measures and the messages. Reasoners shall not produce output except for debugging stuff. If explicit output is required, call this method after reasoning.- Parameters:
prj- the project representing the modelrConfig- the configuration containing the information loggerwithMessages- include the reasoner messages (may be time consuming)
-
logInformation
public void logInformation(Project prj, ReasonerConfiguration.IAdditionalInformationLogger infoLogger, boolean withMessages)
Logs reasoning summary based onprj, the measures and the messages. Reasoners shall not produce output except for debugging stuff. If explicit output is required, call this method after reasoning.- Parameters:
prj- the project representing the modelinfoLogger- the information loggerwithMessages- include the reasoner messages (may be time consuming)
-
-