Package org.rlcommunity.rlglue.codec.taskspec.ranges

Examples of org.rlcommunity.rlglue.codec.taskspec.ranges.IntRange


        TaskSpecVRLGLUE3 theTaskSpecObject = new TaskSpecVRLGLUE3();
        theTaskSpecObject.setEpisodic();
        theTaskSpecObject.setDiscountFactor(1.0d);

        //Specify that there will be an integer observation [0,107] for the state
        theTaskSpecObject.addDiscreteObservation(new IntRange(0, theWorld.getNumStates() - 1));
        //Specify that there will be an integer action [0,3]
        theTaskSpecObject.addDiscreteAction(new IntRange(0, 3));
        //Specify the reward range [-100,10]
        theTaskSpecObject.setRewardRange(new DoubleRange(-100.0d, 10.0d));

        theTaskSpecObject.setExtra("SampleMinesEnvironment(Java) by Brian Tanner.");
View Full Code Here


  //or use the official one but just hard code the string instead of constructing it this way.
      TaskSpecVRLGLUE3 theTaskSpecObject = new TaskSpecVRLGLUE3();
        theTaskSpecObject.setEpisodic();
        theTaskSpecObject.setDiscountFactor(1.0d);
  //Specify that there will be an integer observation [0,20] for the state
        theTaskSpecObject.addDiscreteObservation(new IntRange(0, 20));
  //Specify that there will be an integer action [0,1]
        theTaskSpecObject.addDiscreteAction(new IntRange(0, 1));
  //Specify the reward range [-1,1]
        theTaskSpecObject.setRewardRange(new DoubleRange(-1, 1));

        String taskSpecString = theTaskSpecObject.toTaskSpec();
        TaskSpec.checkTaskSpec(taskSpecString);
View Full Code Here

    public void agent_init(String taskSpecification) {
    TaskSpec theTaskSpec=new TaskSpec(taskSpecification);
    System.out.println("Skeleton agent parsed the task spec.");
    System.out.println("Observation have "+theTaskSpec.getNumDiscreteObsDims()+" integer dimensions");
    System.out.println("Actions have "+theTaskSpec.getNumDiscreteActionDims()+" integer dimensions");
    IntRange theObsRange=theTaskSpec.getDiscreteObservationRange(0);
    System.out.println("Observation (state) range is: "+theObsRange.getMin()+" to "+theObsRange.getMax());
    IntRange theActRange=theTaskSpec.getDiscreteActionRange(0);
    System.out.println("Action range is: "+theActRange.getMin()+" to "+theActRange.getMax());
    DoubleRange theRewardRange=theTaskSpec.getRewardRange();
    System.out.println("Reward range is: "+theRewardRange.getMin()+" to "+theRewardRange.getMax());
   
    //In more complex agents, you would also check for continuous observations and actions, discount factors, etc.
    //Also, these ranges can have special values like "NEGINF, POSINF, UNSPEC (unspecified)".  There is no guarantee
View Full Code Here

            double[] obsMins = V3TaskSpec.getObsMins();
            double[] obsMaxs = V3TaskSpec.getObsMaxs();
            for (int i = 0; i < V3TaskSpec.getObsDim(); i++) {
                AbstractRange newRange = null;
                if (obsTypes[i] == 'i') {
                    newRange = new IntRange((int) obsMins[i], (int) obsMaxs[i]);
                }
                if (obsTypes[i] == 'f') {
                    newRange = new DoubleRange(obsMins[i], obsMaxs[i]);
                }
                if (V3TaskSpec.isObsMinNegInfinity(i)) {
                    newRange.setMinNegInf();
                }
                if (V3TaskSpec.isObsMinUnknown(i)) {
                    newRange.setMinUnspecified();
                }
                if (V3TaskSpec.isObsMaxPosInfinity(i)) {
                    newRange.setMaxInf();
                }
                if (V3TaskSpec.isObsMaxUnknown(i)) {
                    newRange.setMaxUnspecified();
                }
                if (obsTypes[i] == 'i') {
                    intObservations.add((IntRange) newRange);
                }
                if (obsTypes[i] == 'f') {
                    doubleObservations.add((DoubleRange) newRange);
                }
            }
        }
        {
            char[] actTypes = V3TaskSpec.getActionTypes();
            double[] actMins = V3TaskSpec.getActionMins();
            double[] actMaxs = V3TaskSpec.getActionMaxs();
            for (int i = 0; i < V3TaskSpec.getActionDim(); i++) {
                AbstractRange newRange = null;
                if (actTypes[i] == 'i') {
                    newRange = new IntRange((int) actMins[i], (int) actMaxs[i]);
                }
                if (actTypes[i] == 'f') {
                    newRange = new DoubleRange(actMins[i], actMaxs[i]);
                }
                if (V3TaskSpec.isActionMinNegInfinity(i)) {
View Full Code Here

        if (nextToken.equals("INTS")) {
            //Do the ints
            nextToken = T.nextToken();
            while (nextToken.startsWith("(")) {
                String thisRange = nextToken.substring(1) + " " + T.nextToken(")");
                intObservations.add(new IntRange(thisRange));

                //Advance past the space after the range
                T.nextToken(" ");
                nextToken = T.nextToken();
            }
        }
        if (nextToken.equals("DOUBLES")) {
            //Do the doubles
            nextToken = T.nextToken();
            while (nextToken.startsWith("(")) {
                String thisRange = nextToken.substring(1) + " " + T.nextToken(")");
                doubleObservations.add(new DoubleRange(thisRange));

                //Advance past the space after the range
                T.nextToken(" ");
                nextToken = T.nextToken();
            }
        }
        if (nextToken.equals("CHARCOUNT")) {
            String numCharToken = T.nextToken();
            numObsChars = Integer.parseInt(numCharToken);
            nextToken = T.nextToken();

        }

        checkLabel("ACTIONS", nextToken);
        nextToken = T.nextToken();
        if (nextToken.equals("INTS")) {
            //Do the ints
            nextToken = T.nextToken();
            while (nextToken.startsWith("(")) {
                String thisRange = nextToken.substring(1) + " " + T.nextToken(")");
                intActions.add(new IntRange(thisRange));

                //Advance past the space after the range
                T.nextToken(" ");
                nextToken = T.nextToken();
            }
View Full Code Here

        assert (theTaskSpec.toTaskSpec().equals(new TaskSpecVRLGLUE3(theTaskSpec.toTaskSpec()).toTaskSpec()));

        TaskSpecVRLGLUE3 sampleTSO = new TaskSpecVRLGLUE3();
        sampleTSO.setEpisodic();
        sampleTSO.setDiscountFactor(0);
        sampleTSO.addDiscreteObservation(new IntRange(0, 1, 3));
        sampleTSO.addContinuousObservation(new DoubleRange(-1.2, .5, 2));
        sampleTSO.addContinuousObservation(new DoubleRange(-.07, .07));
        sampleTSO.setObservationCharLimit(1024);
        sampleTSO.addDiscreteAction(new IntRange(0, 4));
        sampleTSO.setRewardRange(new DoubleRange(-5, 5));
        sampleTSO.setExtra("some other stuff goes here");
        System.out.println(sampleTSO.toTaskSpec());
        assert (sampleTSO.toTaskSpec().equals(new TaskSpecVRLGLUE3(sampleTSO.toTaskSpec()).toTaskSpec()));
        assert (theTaskSpec.toTaskSpec().equals(sampleTSO.toTaskSpec()));
View Full Code Here

TOP

Related Classes of org.rlcommunity.rlglue.codec.taskspec.ranges.IntRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.