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

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


        //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.");

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


  //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);

    //This actual string this makes is:
View Full Code Here

    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
    //that they are all specified and that they are all nice numbers.
    }
View Full Code Here

                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)) {
                    newRange.setMinNegInf();
                }
                if (V3TaskSpec.isActionMinUnknown(i)) {
                    newRange.setMinUnspecified();
                }
                if (V3TaskSpec.isActionMaxPosInfinity(i)) {
                    newRange.setMaxInf();
                }
                if (V3TaskSpec.isActionMaxUnknown(i)) {
                    newRange.setMaxUnspecified();
                }
                if (actTypes[i] == 'i') {
                    intActions.add((IntRange) newRange);
                }
                if (actTypes[i] == 'f') {
                    doubleActions.add((DoubleRange) newRange);
                }
            }
        }
        rewardRange = new DoubleRange(V3TaskSpec.getRewardMin(), V3TaskSpec.getRewardMax());
        if (V3TaskSpec.isMinRewardNegInf()) {
            rewardRange.setMinNegInf();
        }
        if (V3TaskSpec.isMinRewardUnknown()) {
            rewardRange.setMinUnspecified();
View Full Code Here

        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();
            }
        }
        if (nextToken.equals("DOUBLES")) {
            //Do the doubles
            nextToken = T.nextToken();
            while (nextToken.startsWith("(")) {
                String thisRange = nextToken.substring(1) + " " + T.nextToken(")");
                doubleActions.add(new DoubleRange(thisRange));

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

        }



        checkLabel("REWARDS", nextToken);
        nextToken = T.nextToken();
        if (nextToken.startsWith("(")) {
            String rewardRangeString = nextToken.substring(1) + " " + T.nextToken(")");
            rewardRange = new DoubleRange(rewardRangeString);
            T.nextToken(" ");
            nextToken = T.nextToken();

        }
View Full Code Here

        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.DoubleRange

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.