当前位置: 首页>>代码示例>>Python>>正文


Python pulp.LpVariable方法代码示例

本文整理汇总了Python中pulp.LpVariable方法的典型用法代码示例。如果您正苦于以下问题:Python pulp.LpVariable方法的具体用法?Python pulp.LpVariable怎么用?Python pulp.LpVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp的用法示例。


在下文中一共展示了pulp.LpVariable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_decision_variables

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def _create_decision_variables(self):
        self.production_variables = pulp.LpVariable.dicts(name='X', indexs=self.input_data.index,
                                                          lowBound=0, cat=pulp.LpContinuous)

        self.inventory_variables = pulp.LpVariable.dicts(name='I', indexs=self.input_data.index,
                                                         lowBound=0, cat=pulp.LpContinuous)

        # Alternative way of creating the variables:
        # self.production_variables = {
        #     index: pulp.LpVariable(name='X_' + str(row['period']),
        #                            lowBound=0, cat=pulp.LpContinuous)
        #     for index, row in self.input_data.iterrows()}
        #
        # self.inventory_variables = {
        #     index: pulp.LpVariable(name='I_' + str(row['period']),
        #                            lowBound=0, cat=pulp.LpContinuous)
        #     for index, row in self.input_data.iterrows()}

    # ================== Constraints ================== 
开发者ID:ekhoda,项目名称:optimization-tutorial,代码行数:21,代码来源:optimization_model_pulp.py

示例2: get_objective_function

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def get_objective_function(self, input_data, dmu_code, input_variables,
                               output_variables):
        ''' Generates objective function of input-oriented multiplier model.

            Args:
                input_data (InputData): object that stores input data.
                dmu_code (str): DMU code.
                input_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to input categories.
                output_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to output categories.

            Returns:
                pulp.LpSum: objective function.
        '''
        return pulp.lpSum([input_data.coefficients[dmu_code, category] *
                          output_variables[category]
                          for category in input_data.output_categories]) 
开发者ID:araith,项目名称:pyDEA,代码行数:22,代码来源:multiplier_model.py

示例3: update_objective

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def update_objective(self, input_data, dmu_code, input_variables,
                         output_variables, lp_model):
        ''' Updates coefficients of the objective function of a given model.

            Args:
                input_data (InputData): object that stores input data.
                dmu_code (str): DMU code.
                input_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to input categories.
                output_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to output categories.
                lp_model (pulp.LpProblem): linear programming model.
        '''
        for category in input_data.output_categories:
            lp_model.objective[output_variables[category]] = input_data.coefficients[
                dmu_code, category] 
开发者ID:araith,项目名称:pyDEA,代码行数:20,代码来源:multiplier_model.py

示例4: get_equality_constraint

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def get_equality_constraint(self, input_data, dmu_code, input_variables,
                                output_variables):
        ''' Generates equality constraint of input-oriented multiplier model.

            Args:
                input_data (InputData): object that stores input data.
                dmu_code (str): DMU code.
                input_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to input categories.
                output_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to output categories.

            Returns:
                pulp.LpConstraint: equality constraint.
        '''
        return pulp.lpSum([input_data.coefficients[dmu_code, category] *
                          input_variables[category]
                          for category in input_data.input_categories]) == 1 
开发者ID:araith,项目名称:pyDEA,代码行数:22,代码来源:multiplier_model.py

示例5: update_equality_constraint

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def update_equality_constraint(self, input_data, dmu_code, input_variables,
                                   output_variables, lp_model):
        ''' Updates coefficients of the equality constraint of a given model.

            Args:
                input_data (InputData): object that stores input data.
                dmu_code (str): DMU code.
                input_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to input categories.
                output_variables (dict of str to pulp.LpVariable): dictionary
                    that maps variable name to pulp variable corresponding
                    to output categories.
                lp_model (pulp.LpProblem): linear programming model.
        '''
        for category, var in input_variables.items():
            lp_model.constraints['equality_constraint'][var] = input_data.coefficients[
                dmu_code, category] 
开发者ID:araith,项目名称:pyDEA,代码行数:20,代码来源:multiplier_model.py

示例6: get_input_variable_coefficient

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def get_input_variable_coefficient(self, obj_variable, input_category):
        ''' Returns proper coefficient depending on the fact if variable
            is discretionary or not.

            Args:
                obj_variable (pulp.LpVariable): pulp variable that corresponds
                    to input category of current DMU.
                input_category (str): input category for which current
                    constraint is being created.

            Returns:
                double or pulp.LpVariable: input variable coefficient.

        '''
        if input_category in self.non_disc_inputs:
            return 1
        return obj_variable 
开发者ID:araith,项目名称:pyDEA,代码行数:19,代码来源:envelopment_model.py

示例7: update_output_category_coefficient

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def update_output_category_coefficient(self, current_output, constraint,
                                           obj_var, output_category):
        ''' Updates coefficient of a given output category with a new
            value.

            Args:
                current_output (double): new value for the coefficient.
                constraint (pulp.LpConstraint): constraint whose coefficient
                    should be updated.
                obj_var (pulp.LpVariable): variable of the envelopment
                    model that is optimised in the objective function.
                output_category (str): output category name.
        '''
        if output_category in self.non_disc_outputs:
            constraint.changeRHS(current_output)
        else:
            constraint[obj_var] = -current_output 
开发者ID:araith,项目名称:pyDEA,代码行数:19,代码来源:envelopment_model.py

示例8: _get_variables

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def _get_variables(self):
        ''' Returns proper variables.

            Returns:
                dict of str to pulp.LpVariable: dictionary of
                    pulp variables than maps variable names to pulp variables.

        '''
        raise NotImplementedError() 
开发者ID:araith,项目名称:pyDEA,代码行数:11,代码来源:multiplier_model_decorators.py

示例9: add_variable

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def add_variable(self, name):
        return LpVariable(name, cat=LpBinary) 
开发者ID:DimaKudosh,项目名称:pydfs-lineup-optimizer,代码行数:4,代码来源:pulp_solver.py

示例10: get_output_variable_coefficient

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def get_output_variable_coefficient(self, obj_variable, output_category):
        ''' Returns 1, since in input-oriented model we do not multiply
            current output by anything.

            Args:
                obj_variable (pulp.LpVariable): pulp variable that corresponds
                    to output category of the current DMU.
                output_category (str): output category for which current
                    constraint is being created.

            Returns:
                double: output variable coefficient.
        '''
        return 1 
开发者ID:araith,项目名称:pyDEA,代码行数:16,代码来源:envelopment_model.py

示例11: update_input_category_coefficient

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def update_input_category_coefficient(self, current_input, constraint,
                                          obj_var, input_category):
        ''' Updates coefficient of a given input category with a new
            value.

            Args:
                current_output (double): new value for the coefficient.
                constraint (pulp.LpConstraint): constraint whose coefficient
                    should be updated.
                obj_var (pulp.LpVariable): variable of the envelopment
                    model that is optimised in the objective function.
                output_category (str): input category name.
        '''
        constraint.changeRHS(-current_input) 
开发者ID:araith,项目名称:pyDEA,代码行数:16,代码来源:envelopment_model.py

示例12: _add_constraints_for_outputs

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def _add_constraints_for_outputs(self, variables, dmu_code,
                                     obj_variable):
        ''' Adds constraints for outputs to linear program.

            Args:
                variables (dict of str to pulp.LpVariable): a dictionary
                    that maps DMU codes to pulp.LpVariable, created with
                    pulp.LpVariable.dicts.
                dmu_code (str): DMU code for which LP is being created.
                obj_variable (pulp.LpVariable): LP variable that is optimised
                    (either efficiency score or inverse of efficiency score).
        '''
        self._model_to_decorate._add_constraints_for_outputs(variables,
                                                             dmu_code,
                                                             obj_variable) 
开发者ID:araith,项目名称:pyDEA,代码行数:17,代码来源:envelopment_model_decorators.py

示例13: _add_constraints_for_inputs

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def _add_constraints_for_inputs(self, variables,
                                    dmu_code, obj_variable):
        ''' Adds constraints for inputs to LP.

            Args:
                variables (dict of {str: pulp.LpVariable}): a dictionary that
                    maps DMU codes to pulp.LpVariable, created with
                    pulp.LpVariable.dicts.
                dmu_code (str): DMU code for which LP is being created.
                obj_variable (pulp.LpVariable): LP variable that is optimised
                    (either efficiency score or inverse of efficiency score).
        '''
        self._model_to_decorate._add_constraints_for_inputs(variables,
                                                            dmu_code,
                                                            obj_variable) 
开发者ID:araith,项目名称:pyDEA,代码行数:17,代码来源:envelopment_model_decorators.py

示例14: _create_lp

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def _create_lp(self):
        ''' Creates initial LP.
        '''
        self._model_to_decorate._create_lp()
        self.lp_model = self._model_to_decorate.lp_model

        self._vrs_variable = pulp.LpVariable('VRS_variable', None, None,
                                             pulp.LpContinuous)
        self._model_to_decorate.lp_model.objective += self._vrs_variable

        for dmu_constraint in self._model_to_decorate._dmu_constraint_names.keys():
            self._model_to_decorate.lp_model.constraints[dmu_constraint] += (
                self.multiplier * self._vrs_variable) 
开发者ID:araith,项目名称:pyDEA,代码行数:15,代码来源:multiplier_model_decorators.py

示例15: _change_lower_bound

# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpVariable [as 别名]
def _change_lower_bound(self, variables):
        ''' Changes lower bound for variables corresponding to weakly
            disposable categories.

            Args:
                variables (dict of str to pulp.LpVariable): dictionary of
                    pulp variables than maps variable names to pulp variables.
        '''
        for category, var in variables.items():
            if category in self.weakly_disposable_categories:
                var.lowBound = None 
开发者ID:araith,项目名称:pyDEA,代码行数:13,代码来源:multiplier_model_decorators.py


注:本文中的pulp.LpVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。