def _call_ta( self, config: Configuration, instance: str, instance_specific: str, cutoff: float, seed: int, ) -> typing.Tuple[str, str]: # TODO: maybe replace fixed instance specific and cutoff_length (0) to other value cmd = [] # type: typing.List[str] if not isinstance(self.ta, (list, tuple)): raise TypeError( "self.ta needs to be of type list or tuple, but is %s" % type(self.ta) ) cmd.extend(self.ta) cmd.extend([instance, instance_specific, str(cutoff), "0", str(seed)]) for p in config: if not config.get(p) is None: cmd.extend(["-" + str(p), str(config[p])]) self.logger.debug("Calling: %s" % (" ".join(cmd))) p = Popen(cmd, shell=False, stdout=PIPE, stderr=PIPE, universal_newlines=True) stdout_, stderr_ = p.communicate() self.logger.debug("Stdout: %s" % stdout_) self.logger.debug("Stderr: %s" % stderr_) return stdout_, stderr_
def _call_ta(self, config: Configuration, instance: str, instance_specific: str, cutoff: float, seed: int): # TODO: maybe replace fixed instance specific and cutoff_length (0) to # other value cmd = [] cmd.extend(self.ta) cmd.extend([ "--instance", instance, "--cutoff", str(cutoff), "--seed", str(seed), "--config" ]) for p in config: if not config.get(p) is None: cmd.extend(["-" + str(p), str(config[p])]) self.logger.debug("Calling: %s" % (" ".join(cmd))) p = Popen(cmd, shell=False, stdout=PIPE, stderr=PIPE, universal_newlines=True) stdout_, stderr_ = p.communicate() self.logger.debug("Stdout: %s" % (stdout_)) self.logger.debug("Stderr: %s" % (stderr_)) results = {"status": "CRASHED", "cost": 1234567890} for line in stdout_.split("\n"): if line.startswith("Result of this algorithm run:"): fields = ":".join(line.split(":")[1:]) results = json.loads(fields) return results, stdout_, stderr_
def _call_ta(self, config: Configuration, instance: str, instance_specific: str, cutoff: float, seed: int): # TODO: maybe replace fixed instance specific and cutoff_length (0) to # other value cmd = [] cmd.extend(self.ta) cmd.extend([instance, instance_specific, str(cutoff), "0", str(seed)]) for p in config: if not config.get(p) is None: cmd.extend(["-" + str(p), str(config[p])]) self.logger.debug("Calling: %s" % (" ".join(cmd))) p = Popen(cmd, shell=False, stdout=PIPE, stderr=PIPE, universal_newlines=True) stdout_, stderr_ = p.communicate() self.logger.debug("Stdout: %s" % (stdout_)) self.logger.debug("Stderr: %s" % (stderr_)) return stdout_, stderr_