Esempio n. 1
0
    def __init__(self):
        super(SimulationLearner, self).__init__()
        # specification
        self.specification = SimulationLearnerSpecification()
        self.knowledge = ASGCKnowledge()

        # statistics per knowledge type
        self.trainingOverall = {}
        self.trainAccuracy = {}
        self.trainCount = {}
        self.testAccuracy = {}
        self.testingOverall = {}
        self.testCount = {}

        self.numberPoints = {}
        self.level = {}

        # initialize data container
        self.dataContainer = {}

        # there is one learner per time step
        self._learners = {}

        self._verbose = True
Esempio n. 2
0
 def __init__(self, builder):
     self._builder = builder
     self.__specification = SimulationLearnerSpecification()
     self._builder.getSimulationLearner()\
                  .setSpecification(self.__specification)
Esempio n. 3
0
class SimulationLearnerDescriptor(object):
    """
    Specification descriptor for ASGCSampler
    """

    def __init__(self, builder):
        self._builder = builder
        self.__specification = SimulationLearnerSpecification()
        self._builder.getSimulationLearner()\
                     .setSpecification(self.__specification)

    def withStartingIterationNumber(self, iteration):
        """
        Set the starting iteration number
        @param iteration: integer starting iteration number
        """
        self._builder.getSimulationLearner().setCurrentIterationNumber(iteration)
        return self

    def withRefinement(self):
        """
        Define if spatially adaptive refinement should be done and how...
        """
        return RefinementDescriptor(self._builder)

    def withParameters(self, params):
        """
        Set the parameter setting
        @param params: ParameterSet
        """
        self.__specification.setParameters(params)
        return self

    def withQoI(self, qoi):
        """
        Define, which quantity of interest we study.
        @param qoi: string quantity of interest
        """
        self.__specification.setQoI(qoi)
        return self

    def withTypesOfKnowledge(self, knowledgeTypes):
        """
        Define for which type of functions the hierarchical coefficients are
        computed using the specified learner.
        @param knowledgeTypes: list of KnowledgetTypes
        """
        self.__specification.setKnowledgeTypes(knowledgeTypes)
        return self

    def withTimeStepsOfInterest(self, ts):
        """
        Define the time steps in which we are interested in. The learner
        just learns those, which are specified here. Moreover, it considers
        just this time steps for refinement.
        @param ts: list of floats, time steps
        """
        # check for uniqueness of time steps
        if len(ts) != len(set(ts)):
            raise AttributeError('time steps of interest are not unique')
        self.__specification.setTimeStepsOfInterest(ts)
        return self

    def withAdaptThreshold(self, value):
        """
        Specifies refinement threshold
        @param value: float for refinement threshold
        """
        self.__specification.setAdaptThreshold(value)
        return self

    def withAdaptPoints(self, value):
        """
        Specifies number of points, which have to be refined in refinement step
        @param value: integer for number of points to refine
        """
        self.__specification.setAdaptPoints(value)
        return self

    def withAdaptRate(self, value):
        """
        Specifies rate from total number of points on grid, which should be
        refined.
        @param value: float for rate
        """
        self.__specification.setAdaptRate(value)
        return self