@Test public void testSampleInitialStateDistribution() throws Exception { CartPoleState state = environment.sampleInitialStateDistribution(random); Assert.assertEquals(state.getCartPosition(), 0, 0.001); Assert.assertEquals(state.getCartVelocity(), 0, 0.001); Assert.assertEquals(state.getPoleVelocity(0), 0, 0.001); Assert.assertEquals(state.getPoleAngle(0), 0.07, 0.001); Assert.assertEquals(state.getPoleVelocity(1), 0, 0.001); Assert.assertEquals(state.getPoleAngle(1), 0, 0.001); Assert.assertArrayEquals(new double[] { 0, 0, 0.07, 0, 0, 0 }, state.getFeatures(), 0.001); }
@Override public CartPoleState sampleInitialStateDistribution(RandomDataGenerator random) { double[] initialAngles = new double[numPoles]; double[] initialVelocities = new double[numPoles]; initialAngles[0] = FOUR_DEGREES; return new CartPoleState(0, 0, initialAngles, initialVelocities); }
CartPoleEnvironment implements Environment<CartPoleState, ContinuousAction>,
		EnvironmentEncoder<CartPoleState, ContinuousAction>, Serializable { @Override public CartPoleState sampleInitialStateDistribution(RandomDataGenerator random) { double[] initialAngles = new double[numPoles]; double[] initialVelocities = new double[numPoles]; initialAngles[0] = FOUR_DEGREES; return new CartPoleState(0, 0, initialAngles, initialVelocities); } }
CartPoleEnvironment implements Environment<CartPoleState, ContinuousAction>,
		EnvironmentEncoder<CartPoleState, ContinuousAction>, Serializable { @Override public CartPoleState sampleInitialStateDistribution(RandomDataGenerator random) { double[] initialAngles = new double[numPoles]; double[] initialVelocities = new double[numPoles]; initialAngles[0] = FOUR_DEGREES; return new CartPoleState(0, 0, initialAngles, initialVelocities); } CartPoleEnvironment(int numPoles);  CartPoleEnvironment(int numPoles, double[] poleLengths, double[] poleMasses, double cartMass);  CartPoleEnvironment(int numPoles, double[] poleLengths, double[] poleMasses, double cartMass, double gravity); }
CartPoleEnvironment implements Environment<CartPoleState, ContinuousAction>,
		EnvironmentEncoder<CartPoleState, ContinuousAction>, Serializable { @Override public CartPoleState sampleInitialStateDistribution(RandomDataGenerator random) { double[] initialAngles = new double[numPoles]; double[] initialVelocities = new double[numPoles]; initialAngles[0] = FOUR_DEGREES; return new CartPoleState(0, 0, initialAngles, initialVelocities); } CartPoleEnvironment(int numPoles);  CartPoleEnvironment(int numPoles, double[] poleLengths, double[] poleMasses, double cartMass);  CartPoleEnvironment(int numPoles, double[] poleLengths, double[] poleMasses, double cartMass, double gravity); double[] getPoleMasses(); double[] getPoleLengths(); double getCartMass(); double getGravity(); int getNumPoles(); @Override AgentTransition<CartPoleState, ContinuousAction> getAgentTransition(CartPoleState state,
			ContinuousAction action); void step(double force, double[] variables, double[] derivatives); void motionEquations(double force, double[] variables, double[] derivatives); void RungeKutta4(double force, double[] y, double[] dydx, double[] yout); @Override EnvTransition<CartPoleState> getEnvironmentTransition(CartPoleState afterState,
			RandomDataGenerator random); @Override List<ContinuousAction> getPossibleActions(CartPoleState state); @Override CartPoleState sampleInitialStateDistribution(RandomDataGenerator random); @Override boolean isTerminal(CartPoleState state); @Override double getAgentPerformance(double totalReward, int numSteps, CartPoleState finalState); @Override double[] encode(CartPoleState state); int getNumInputs(); @Override double[] encode(ContinuousAction action); double evaluate(RealFunction controller, int maxNumSteps, RandomDataGenerator random); @Override String toString(); }
CartPoleEnvironment implements Environment<CartPoleState, ContinuousAction>,
		EnvironmentEncoder<CartPoleState, ContinuousAction>, Serializable { @Override public CartPoleState sampleInitialStateDistribution(RandomDataGenerator random) { double[] initialAngles = new double[numPoles]; double[] initialVelocities = new double[numPoles]; initialAngles[0] = FOUR_DEGREES; return new CartPoleState(0, 0, initialAngles, initialVelocities); } CartPoleEnvironment(int numPoles);  CartPoleEnvironment(int numPoles, double[] poleLengths, double[] poleMasses, double cartMass);  CartPoleEnvironment(int numPoles, double[] poleLengths, double[] poleMasses, double cartMass, double gravity); double[] getPoleMasses(); double[] getPoleLengths(); double getCartMass(); double getGravity(); int getNumPoles(); @Override AgentTransition<CartPoleState, ContinuousAction> getAgentTransition(CartPoleState state,
			ContinuousAction action); void step(double force, double[] variables, double[] derivatives); void motionEquations(double force, double[] variables, double[] derivatives); void RungeKutta4(double force, double[] y, double[] dydx, double[] yout); @Override EnvTransition<CartPoleState> getEnvironmentTransition(CartPoleState afterState,
			RandomDataGenerator random); @Override List<ContinuousAction> getPossibleActions(CartPoleState state); @Override CartPoleState sampleInitialStateDistribution(RandomDataGenerator random); @Override boolean isTerminal(CartPoleState state); @Override double getAgentPerformance(double totalReward, int numSteps, CartPoleState finalState); @Override double[] encode(CartPoleState state); int getNumInputs(); @Override double[] encode(ContinuousAction action); double evaluate(RealFunction controller, int maxNumSteps, RandomDataGenerator random); @Override String toString(); static final int NUM_INPUTS_ONE_POLE; static final int NUM_INPUTS_TWO_POLES; }