private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
if (t instanceof RuntimeException) {
throw new RuntimeMBeanException((RuntimeException)t,
"RuntimeException thrown " + where);
} else if (t instanceof Error) {
throw new RuntimeErrorException((Error)t,
"Error thrown " + where);
} else if (t instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException)t;
} else if (t instanceof Exception) {
throw new MBeanRegistrationException((Exception)t,
"Exception thrown " + where);
} else // neither Error nor Exception??
throw new RuntimeException(t);
}
java类javax.management.RuntimeErrorException的实例源码
DefaultMBeanServerInterceptor.java 文件源码
项目:OpenJSharp
阅读 27
收藏 0
点赞 0
评论 0
DefaultMBeanServerInterceptor.java 文件源码
项目:OpenJSharp
阅读 26
收藏 0
点赞 0
评论 0
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:OpenJSharp
阅读 26
收藏 0
点赞 0
评论 0
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:jdk8u-jdk
阅读 27
收藏 0
点赞 0
评论 0
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
if (t instanceof RuntimeException) {
throw new RuntimeMBeanException((RuntimeException)t,
"RuntimeException thrown " + where);
} else if (t instanceof Error) {
throw new RuntimeErrorException((Error)t,
"Error thrown " + where);
} else if (t instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException)t;
} else if (t instanceof Exception) {
throw new MBeanRegistrationException((Exception)t,
"Exception thrown " + where);
} else // neither Error nor Exception??
throw new RuntimeException(t);
}
DefaultMBeanServerInterceptor.java 文件源码
项目:jdk8u-jdk
阅读 26
收藏 0
点赞 0
评论 0
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:jdk8u-jdk
阅读 22
收藏 0
点赞 0
评论 0
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
if (t instanceof RuntimeException) {
throw new RuntimeMBeanException((RuntimeException)t,
"RuntimeException thrown " + where);
} else if (t instanceof Error) {
throw new RuntimeErrorException((Error)t,
"Error thrown " + where);
} else if (t instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException)t;
} else if (t instanceof Exception) {
throw new MBeanRegistrationException((Exception)t,
"Exception thrown " + where);
} else // neither Error nor Exception??
throw new RuntimeException(t);
}
DefaultMBeanServerInterceptor.java 文件源码
项目:openjdk-jdk10
阅读 21
收藏 0
点赞 0
评论 0
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.log(Level.DEBUG, "While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:openjdk9
阅读 24
收藏 0
点赞 0
评论 0
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
if (t instanceof RuntimeException) {
throw new RuntimeMBeanException((RuntimeException)t,
"RuntimeException thrown " + where);
} else if (t instanceof Error) {
throw new RuntimeErrorException((Error)t,
"Error thrown " + where);
} else if (t instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException)t;
} else if (t instanceof Exception) {
throw new MBeanRegistrationException((Exception)t,
"Exception thrown " + where);
} else // neither Error nor Exception??
throw new RuntimeException(t);
}
DefaultMBeanServerInterceptor.java 文件源码
项目:openjdk9
阅读 36
收藏 0
点赞 0
评论 0
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:openjdk9
阅读 25
收藏 0
点赞 0
评论 0
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
EasyMath.java 文件源码
项目:easyMath
阅读 25
收藏 0
点赞 0
评论 0
public static int[][] multiply2DMatrix(int[][] firstMatrix,
int[][] secondMatrix) {
int[][] result = new int[firstMatrix.length][secondMatrix[0].length];
if (firstMatrix[0].length == secondMatrix.length) {
for (int i = 0; i < firstMatrix.length; i++) {
for (int j = 0; j < secondMatrix[0].length; j++) {
for (int k = 0; k < firstMatrix[0].length; k++) {
result[i][j] += firstMatrix[i][k] * secondMatrix[k][j];
}
}
}
} else {
throw new RuntimeErrorException(null,
"Column number of first matrix" + "("
+ firstMatrix[0].length
+ ") is not equal to row number" + "("
+ secondMatrix.length + ") of second matrix");
}
return result;
}
EasyMath.java 文件源码
项目:easyMath
阅读 18
收藏 0
点赞 0
评论 0
public static double determinant2DMatrix(double[][] matrix)
throws Exception {
int n = matrix.length - 1;
int m = matrix[0].length;
if (n + 1 == m) {
if (n < 0)
return 0;
double Matrix[][][] = new double[n + 1][][];
Matrix[n] = matrix; //
for (int i = 0; i < n; i++)
Matrix[i] = new double[i + 1][i + 1];
return Helper(Matrix, n);
} else {
Error e = new Error("Matematik");
throw new RuntimeErrorException(e, "Given matrix is not square!");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:jdk8u_jdk
阅读 21
收藏 0
点赞 0
评论 0
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
if (t instanceof RuntimeException) {
throw new RuntimeMBeanException((RuntimeException)t,
"RuntimeException thrown " + where);
} else if (t instanceof Error) {
throw new RuntimeErrorException((Error)t,
"Error thrown " + where);
} else if (t instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException)t;
} else if (t instanceof Exception) {
throw new MBeanRegistrationException((Exception)t,
"Exception thrown " + where);
} else // neither Error nor Exception??
throw new RuntimeException(t);
}
DefaultMBeanServerInterceptor.java 文件源码
项目:jdk8u_jdk
阅读 25
收藏 0
点赞 0
评论 0
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:jdk8u_jdk
阅读 22
收藏 0
点赞 0
评论 0
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 25
收藏 0
点赞 0
评论 0
private static void throwMBeanRegistrationException(Throwable t, String where)
throws MBeanRegistrationException {
if (t instanceof RuntimeException) {
throw new RuntimeMBeanException((RuntimeException)t,
"RuntimeException thrown " + where);
} else if (t instanceof Error) {
throw new RuntimeErrorException((Error)t,
"Error thrown " + where);
} else if (t instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException)t;
} else if (t instanceof Exception) {
throw new MBeanRegistrationException((Exception)t,
"Exception thrown " + where);
} else // neither Error nor Exception??
throw new RuntimeException(t);
}
DefaultMBeanServerInterceptor.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 25
收藏 0
点赞 0
评论 0
private static void postRegister(
ObjectName logicalName, DynamicMBean mbean,
boolean registrationDone, boolean registerFailed) {
if (registerFailed && mbean instanceof DynamicMBean2)
((DynamicMBean2) mbean).registerFailed();
try {
if (mbean instanceof MBeanRegistration)
((MBeanRegistration) mbean).postRegister(registrationDone);
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Exception thrown by postRegister: " +
"rethrowing <"+e+">, but keeping the MBean registered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method: "+
"rethrowing <"+e+">, but keeping the MBean registered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While registering MBean ["+logicalName+
"]: " + "Error thrown by postRegister: " +
"rethrowing <"+er+">, but keeping the MBean registered");
throw new RuntimeErrorException(er,
"Error thrown in postRegister method: "+
"rethrowing <"+er+">, but keeping the MBean registered");
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 23
收藏 0
点赞 0
评论 0
private static void postDeregisterInvoke(ObjectName mbean,
MBeanRegistration moi) {
try {
moi.postDeregister();
} catch (RuntimeException e) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Exception thrown by postDeregister: " +
"rethrowing <"+e+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeMBeanException(e,
"RuntimeException thrown in postDeregister method: "+
"rethrowing <"+e+
">, although the MBean is sucessfully unregistered");
} catch (Error er) {
MBEANSERVER_LOGGER.fine("While unregistering MBean ["+mbean+
"]: " + "Error thrown by postDeregister: " +
"rethrowing <"+er+">, although the MBean is succesfully " +
"unregistered");
throw new RuntimeErrorException(er,
"Error thrown in postDeregister method: "+
"rethrowing <"+er+
">, although the MBean is sucessfully unregistered");
}
}
DeterministicTerminationOption.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 19
收藏 0
点赞 0
评论 0
/**
* Initializes the option by creating the policy uses some provided option. The valueFunction is called repeatedly on each state in the
* the list <code>seedStatesForPlanning</code> and then
* sets this options policy to the valueFunction derived policy that is provided.
* @param name the name of the option
* @param init the initiation conditions of the option
* @param terminationStates the termination states of the option
* @param seedStatesForPlanning the states that should be used as initial states for the valueFunction
* @param planner the valueFunction that is used to create the policy for this option
* @param p the valueFunction derived policy to use after planning from each initial state is performed.
*/
public DeterministicTerminationOption(String name, StateConditionTest init, StateConditionTest terminationStates, List<State> seedStatesForPlanning,
Planner planner, SolverDerivedPolicy p){
if(!(p instanceof Policy)){
throw new RuntimeErrorException(new Error("PlannerDerivedPolicy p is not an instnace of Policy"));
}
this.name = name;
this.initiationTest = init;
this.terminationStates = terminationStates;
//now construct the policy using the valueFunction from each possible initiation state
for(State si : seedStatesForPlanning){
planner.planFromState(si);
}
p.setSolver(planner);
this.policy = (Policy)p;
}
QLearning.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 20
收藏 0
点赞 0
评论 0
/**
* Returns the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
* is stored, then it is created and has its Q-value initialize using this objects {@link burlap.behavior.valuefunction.ValueFunctionInitialization} data member.
* @param s the hashed state for which to get the {@link QLearningStateNode} object
* @return the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
*/
protected QLearningStateNode getStateNode(HashableState s){
QLearningStateNode node = qIndex.get(s);
if(node == null){
node = new QLearningStateNode(s);
List<GroundedAction> gas = this.getAllGroundedActions(s.s);
if(gas.size() == 0){
gas = this.getAllGroundedActions(s.s);
throw new RuntimeErrorException(new Error("No possible actions in this state, cannot continue Q-learning"));
}
for(GroundedAction ga : gas){
node.addQValue(ga, qInitFunction.qValue(s.s, ga));
}
qIndex.put(s, node);
}
return node;
}
CMACFeatureDatabase.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 19
收藏 0
点赞 0
评论 0
/**
* Causes the <code>i</code>th tiling in this CMAC to be defined over the given attribute for the given OO-MDP class. Along that
* dimension, the tiling will have a width of <code>windowSize</code>.
* @param className the OO-MDP class name for which the provided attribute will be tiled.
* @param attribute the OO-MDP attribute that will be tiled
* @param windowSize the width of tilings over the specified attribute and OO-MDP class.
*/
public void addSpecificaitonForTiling(int i, String className, Attribute attribute, double windowSize){
double bucketBoundary = 0.;
if(this.arrangement == TilingArrangement.RANDOMJITTER){
bucketBoundary = rand.nextDouble()*windowSize;
}
else if(this.arrangement == TilingArrangement.UNIFORM){
bucketBoundary = ((double)i / (double)nTilings)*windowSize;
}
else{
throw new RuntimeErrorException(new Error("Unknown CMAC tiling arrangement type"));
}
Tiling tiling = tilings.get(i);
tiling.addSpecification(className, attribute, windowSize, bucketBoundary);
}
BoltzmannDistribution.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 23
收藏 0
点赞 0
评论 0
/**
* Samples the output probability distribution.
* @return the index of the sampled element
*/
public int sample(){
if(this.needsUpdate){
this.computeProbs();
}
double r = this.rand.nextDouble();
double sum = 0.;
for(int i = 0; i < this.probs.length; i++){
sum += this.probs[i];
if(r < sum){
return i;
}
}
throw new RuntimeErrorException(new Error("Error in sample; Boltzmann distribution did not sum to 1"));
}
GoldMineSAAlgorithmQLearning.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 21
收藏 0
点赞 0
评论 0
/**
* Returns the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
* is stored, then it is created and has its Q-value initialize using this objects {@link burlap.behavior.valuefunction.ValueFunctionInitialization} data member.
* @param s the hashed state for which to get the {@link QLearningStateNode} object
* @return the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
*/
@Override
protected QLearningStateNode getStateNode(HashableState s){
//System.out.println("getStateNode");
QLearningStateNode node = qIndex.get(s);
if(node == null){
node = new QLearningStateNode(s);
List<GroundedAction> gas = this.getAllGroundedActions(s.s);
if(gas.size() == 0){
gas = this.getAllGroundedActions(s.s);
throw new RuntimeErrorException(new Error("No possible actions in this state, cannot continue Q-learning"));
}
for(GroundedAction ga : gas){
if(ga.applicableInState(s.s)){
node.addQValue(ga, qInitFunction.qValue(s.s, ga));
this.qTableSize++;
}
}
qIndex.put(s, node);
}
return node;
}
DeterministicTerminationOption.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 20
收藏 0
点赞 0
评论 0
/**
* Initializes the option by creating the policy uses some provided option. The valueFunction is called repeatedly on each state in the
* the list <code>seedStatesForPlanning</code> and then
* sets this options policy to the valueFunction derived policy that is provided.
* @param name the name of the option
* @param init the initiation conditions of the option
* @param terminationStates the termination states of the option
* @param seedStatesForPlanning the states that should be used as initial states for the valueFunction
* @param planner the valueFunction that is used to create the policy for this option
* @param p the valueFunction derived policy to use after planning from each initial state is performed.
*/
public DeterministicTerminationOption(String name, StateConditionTest init, StateConditionTest terminationStates, List<State> seedStatesForPlanning,
Planner planner, SolverDerivedPolicy p){
if(!(p instanceof Policy)){
throw new RuntimeErrorException(new Error("PlannerDerivedPolicy p is not an instnace of Policy"));
}
this.name = name;
this.initiationTest = init;
this.terminationStates = terminationStates;
//now construct the policy using the valueFunction from each possible initiation state
for(State si : seedStatesForPlanning){
planner.planFromState(si);
}
p.setSolver(planner);
this.policy = (Policy)p;
}
QLearning.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 19
收藏 0
点赞 0
评论 0
/**
* Returns the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
* is stored, then it is created and has its Q-value initialize using this objects {@link burlap.behavior.valuefunction.ValueFunctionInitialization} data member.
* @param s the hashed state for which to get the {@link QLearningStateNode} object
* @return the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
*/
protected QLearningStateNode getStateNode(HashableState s){
QLearningStateNode node = qIndex.get(s);
if(node == null){
node = new QLearningStateNode(s);
List<GroundedAction> gas = this.getAllGroundedActions(s.s);
if(gas.size() == 0){
gas = this.getAllGroundedActions(s.s);
throw new RuntimeErrorException(new Error("No possible actions in this state, cannot continue Q-learning"));
}
for(GroundedAction ga : gas){
node.addQValue(ga, qInitFunction.qValue(s.s, ga));
}
qIndex.put(s, node);
}
return node;
}
CMACFeatureDatabase.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 19
收藏 0
点赞 0
评论 0
/**
* Causes the <code>i</code>th tiling in this CMAC to be defined over the given attribute for the given OO-MDP class. Along that
* dimension, the tiling will have a width of <code>windowSize</code>.
* @param className the OO-MDP class name for which the provided attribute will be tiled.
* @param attribute the OO-MDP attribute that will be tiled
* @param windowSize the width of tilings over the specified attribute and OO-MDP class.
*/
public void addSpecificaitonForTiling(int i, String className, Attribute attribute, double windowSize){
double bucketBoundary = 0.;
if(this.arrangement == TilingArrangement.RANDOMJITTER){
bucketBoundary = rand.nextDouble()*windowSize;
}
else if(this.arrangement == TilingArrangement.UNIFORM){
bucketBoundary = ((double)i / (double)nTilings)*windowSize;
}
else{
throw new RuntimeErrorException(new Error("Unknown CMAC tiling arrangement type"));
}
Tiling tiling = tilings.get(i);
tiling.addSpecification(className, attribute, windowSize, bucketBoundary);
}
BoltzmannDistribution.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 24
收藏 0
点赞 0
评论 0
/**
* Samples the output probability distribution.
* @return the index of the sampled element
*/
public int sample(){
if(this.needsUpdate){
this.computeProbs();
}
double r = this.rand.nextDouble();
double sum = 0.;
for(int i = 0; i < this.probs.length; i++){
sum += this.probs[i];
if(r < sum){
return i;
}
}
throw new RuntimeErrorException(new Error("Error in sample; Boltzmann distribution did not sum to 1"));
}
DistributedQTable.java 文件源码
项目:DOO-Q_BRACIS2016
阅读 22
收藏 0
点赞 0
评论 0
/**
* Returns the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
* is stored, then it is created and has its Q-value initialize using this objects {@link burlap.behavior.valuefunction.ValueFunctionInitialization} data member.
* @param s the hashed state for which to get the {@link QLearningStateNode} object
* @return the {@link QLearningStateNode} object stored for the given hashed state. If no {@link QLearningStateNode} object.
*/
protected QLearningStateNode getStateNode(HashableState s){
QLearningStateNode node = qValues.get(s);
if(node == null){
node = new QLearningStateNode(s);
List<GroundedSGAgentAction> gas;
gas = this.getAllGroundedActions(s.s);
if(gas.size() == 0){
throw new RuntimeErrorException(new Error("No possible actions in this state, cannot continue Q-learning"));
}
for(GroundedSGAgentAction ga : gas){
if(ga.applicableInState(s.s)){
node.addQValue(ga, qInit.qValue(s.s, ga));
this.entriesNumber++;
}
}
qValues.put(s, node);
}
return node;
}