예제 #1
0
    def _add_production_variables(num_types: int, num_time_periods: int,
                                  solver: Solver) -> Dict[V, Variable]:
        """Create production variables.

        A production variable $x^t_p$ is a binary variable which is one if and only if an item of
        type $t$ is produced in time period $p$.

        :param num_types: the number of considered types
        :param num_time_periods: the number of considered time periods
        :param solver: the underlying solver for which to built the variables
        :return: A dictionary mapping each production variable to its solver variable
        """
        production_vars = dict()
        for (item_type, time_period) in product(range(num_types),
                                                range(num_time_periods)):
            production_vars[V(type=item_type,
                              period=time_period)] = solver.BoolVar(
                                  name=f'x_{item_type}_{time_period}')
        module_logger.info(
            f'Created {len(production_vars)} production variables.')
        return production_vars
예제 #2
0
    def _add_configuration_variables(num_types: int, num_time_periods: int, solver: Solver) \
            -> Dict[V, Variable]:
        """Create configuration variables.

        A configuration variable $y^t_p$ is a binary variable which is one if and only if the
        machine is configured for type $t$ in time period $p$.

        :param num_types: the number of considered types
        :param num_time_periods: the number of considered time periods
        :param solver: the underlying solver for which to built the variables
        :return: A dictionary mapping each configuration tuple to its solver variable

        """
        configuration_vars = dict()
        for (item_type, time_period) in product(range(num_types),
                                                range(num_time_periods)):
            configuration_vars[V(type=item_type,
                                 period=time_period)] = solver.BoolVar(
                                     name=f'y_{item_type}_{time_period}')
        module_logger.info(
            f'Created {len(configuration_vars)} configuration variables.')
        return configuration_vars
예제 #3
0
    def _add_transition_variables(num_types: int, num_time_periods: int, solver: Solver) \
            -> Dict[W, Variable]:
        """Create transition variables.

        A transition variable $u^ij_p$ is a binary variable which is one if and only if the
        machine's configuration changes from type $i$ to type $j$ in time period $p$.

        :param num_types: the number of considered types
        :param num_time_periods: the number of considered time periods
        :param solver: the underlying solver for which to built the variables
        :return: A dictionary mapping each transition variable to its solver variable
        """
        transition_vars = dict()
        for type_i, type_j, time_period in product(range(num_types),
                                                   range(num_types),
                                                   range(1, num_time_periods)):
            transition_vars[W(from_type=type_i,
                              to_type=type_j,
                              from_period=time_period - 1,
                              to_period=time_period)] = solver.BoolVar(
                                  name=f'u_{type_i}_{type_j}_{time_period}')
        module_logger.info(
            f'Created {len(transition_vars)} transition variables.')
        return transition_vars