Exemple #1
0
    def start(self,
              config: Configuration,
              instance: str,
              cutoff: float = None,
              seed: int = 12345,
              instance_specific: str = "0",
              capped: bool = False):
        """
        wrapper function for ExecuteTARun.start() to cap the target algorithm
        runtime if it would run over the total allowed runtime.

        Parameters
        ----------
            config : Configuration
                mainly a dictionary param -> value
            instance : string
                problem instance
            cutoff : float
                runtime cutoff
            seed : int
                random seed
            instance_specific: str
                instance specific information (e.g., domain file or solution)
            capped: bool
                if true and status is StatusType.TIMEOUT,
                uses StatusType.CAPPED
        Returns
        -------
            status: enum of StatusType (int)
                {SUCCESS, TIMEOUT, CRASHED, ABORT}
            cost: float
                cost/regret/quality (float) (None, if not returned by TA)
            runtime: float
                runtime (None if not returned by TA)
            additional_info: dict
                all further additional run information
        """
        remaining_time = self.stats.get_remaing_time_budget()

        if remaining_time - 5 < cutoff:
            cutoff = int(remaining_time - 5)

        if cutoff <= 1.0:
            raise BudgetExhaustedException()
        cutoff = int(cutoff)

        return super().start(config=config,
                             instance=instance,
                             cutoff=cutoff,
                             seed=seed,
                             instance_specific=instance_specific,
                             capped=capped)
Exemple #2
0
    def start(self, config: Configuration,
              instance: Optional[str],
              cutoff: float = None,
              seed: int = 12345,
              budget: float = 0.0,
              instance_specific: Optional[str] = None,
              capped: bool = False):
        """
        wrapper function for ExecuteTARun.start() to cap the target algorithm
        runtime if it would run over the total allowed runtime.

        Parameters
        ----------
            config : Configuration
                mainly a dictionary param -> value
            instance : string
                problem instance
            cutoff : float
                runtime cutoff
            seed : int
                random seed
            budget : float
                A positive, real-valued number representing an arbitrary limit to the target
                algorithm. Handled by the target algorithm internally
            instance_specific: str
                instance specific information (e.g., domain file or solution)
            capped: bool
                if true and status is StatusType.TIMEOUT,
                uses StatusType.CAPPED
        Returns
        -------
            status: enum of StatusType (int)
                {SUCCESS, TIMEOUT, CRASHED, ABORT}
            cost: float
                cost/regret/quality (float) (None, if not returned by TA)
            runtime: float
                runtime (None if not returned by TA)
            additional_info: dict
                all further additional run information
        """
        if self.budget_type is None:
            if budget != 0:
                raise ValueError('If budget_type is None, budget must be.0, but is %f' % budget)
        else:
            if budget == 0:
                budget = 100
            elif budget <= 0 or budget > 100:
                raise ValueError('Illegal value for budget, must be >0 and <=100, but is %f' %
                                 budget)
            if self.budget_type not in ('subsample', 'iterations', 'mixed'):
                raise ValueError("Illegal value for budget type, must be one of "
                                 "('subsample', 'iterations', 'mixed'), but is : %s" %
                                 self.budget_type)

        remaining_time = self.stats.get_remaing_time_budget()

        if remaining_time - 5 < cutoff:
            cutoff = int(remaining_time - 5)

        if cutoff < 1.0:
            raise BudgetExhaustedException()
        cutoff = int(np.ceil(cutoff))

        return super().start(config=config, instance=instance, cutoff=cutoff,
                             seed=seed, instance_specific=instance_specific,
                             capped=capped, budget=budget)