How to use the docplex.mp.model function in docplex

To help you get started, we’ve selected a few docplex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ekhoda / optimization-tutorial / execute_docplex.py View on Github external
I_0: initial_inventory
c_t: unit production cost in month t
d_t: demand of month t

Variables:
X_t: Amount produced in month t
I_t: Inventory at the end of period t

Constraints:
Inventory Constraints: I_{t-1} + X_t - d_t = I_t
Capacity Constraints: X_t <= p

Objective: Min Sum(h*I_t + c_t*X_t)
"""

model = cpx.Model('prod_planning')

start = time()

# ================== Decision variables ==================
production_variables = model.continuous_var_dict(input_df_dict['input_data'].index, name="X")
inventory_variables = model.continuous_var_dict(input_df_dict['input_data'].index, name="I")

# Alternative way of creating the variables
# production_variables = {index: model.continuous_var(name='X_' + str(row['period']))
#                         for index, row in input_df_dict['input_data'].iterrows()}
#
# inventory_variables = {index: model.continuous_var(name='I_' + str(row['period']))
#                        for index, row in input_df_dict['input_data'].iterrows()}

logger.debug("var declaration time: {:.6f}".format(time() - start))
github ekhoda / optimization-tutorial / optimization_model_docplex.py View on Github external
def __init__(self, input_data, input_params):
        self.input_data = input_data
        self.input_params = input_params
        self.model = cpx.Model('prod_planning')
        self._create_decision_variables()
        self._create_main_constraints()
        self._set_objective_function()

docplex

The IBM Decision Optimization CPLEX Modeling for Python

Apache-2.0
Latest version published 4 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages