Esempio n. 1
0
    def set_status_quo_with_weight(self, status_quo: Arm, weight: float) -> BatchTrial:
        """Sets status quo arm with given weight. This weight *overrides* any
        weight the status quo has from generator runs attached to this batch.
        Thus, this function is not the same as using add_arm, which will
        result in the weight being additive over all generator runs.
        """
        # Assign a name to this arm if none exists
        if weight is not None and weight <= 0.0:
            raise ValueError("Status quo weight must be positive.")

        if status_quo is not None:
            self.experiment.search_space.check_types(
                status_quo.parameters, raise_error=True
            )
            self.experiment._name_and_store_arm_if_not_exists(
                arm=status_quo, proposed_name="status_quo_" + str(self.index)
            )
        self._status_quo = status_quo.clone() if status_quo is not None else None
        self._status_quo_weight_override = weight
        self._refresh_arms_by_name()
        return self
Esempio n. 2
0
 def testClone(self):
     arm1 = Arm(parameters={"y": 0.25, "x": 0.75, "z": 75})
     arm2 = arm1.clone()
     self.assertFalse(arm1 is arm2)
     self.assertEqual(arm1, arm2)
     self.assertFalse(arm1.parameters is arm2.parameters)