I'm dealing with a kind of assignment problem, in which I have a set of tasks $t$ to be executed by machines $w$, but these tasks depend on the variatns $v$ of components $m$ being selected, which is stated by decision variable $Y_{mv}$.

I would like to ensure that all selected components will satisfy a set of requirements when creating a given product composed of many components. Besides that, I would like to ensure that all the selected components' tasks will be fulfilled somewhere in a process plan.

Considering the following parameters:

Let $F = 1, 3, 4,...$ be the set of requirements to be satisfied.

Let $M = 1, 2, 3,...$ be the set of components that can appear in a product.

Let $V_{M} = 1, 2, 3, ...$ be the set of variants $v$ of a given component $m$ in $M$

Let $T = 1, 2, 3, ...$ be the set of available tasks

Let $R_{mvt}=1$ a parameter that states if variant $v$ of component $m$ requires task $t$, $0$ otherwise

Let $S_{mvf}=1$ a parameter that states if variant $v$ of component $m$ satisfies the requirement $f$, $0$ otherwise

Considering the following decision variables:

$X_{twj}=1$ if task $t$ is performed by machine $w$ in process plan position $j$, $0$ otherwise

$Y_{mv}=1$ if variant $v$ of component $m$ is selected in the product, $0$ otherwise

My objectives are:

  • Ensuring that, besides all available tasks, only the tasks required by the selected variants $v$ of components $m$ will be performed (first equation)
  • Ensuring that all requirements will be satisfied by the selected variants $v$ of components $m$ (second equation)

$$ \begin{align} \sum_{m} \sum_{v} Y_{mv}*S_{mvf} &= 1 & \forall f in F\\ \sum_{m} \sum_{v} Y_{mv}*R_{mvt} &= \sum_{t} \sum_{w} \sum_{j}X_{twj} \\ \end{align} $$

How to state a constraint to ensure that only the required tasks will be executed?

EDIT: I am using cplex, and when I run the code using the constraints above, it does not return any result (model is infeasible as suggested by @Alex Fleischer).

AttributeError: 'NoneType' object has no attribute 'get_objective_value'

I suppose that the constraints are not well established, but I still have not identified where the problem is. Could someone help with this trouble?


I guess your model is not feasible.

Let me use the tiny zoo example:

from docplex.mp.model import Model

mdl = Model(name='buses')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')
mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids')

mdl.minimize(nbbus40*500 + nbbus30*400)


print("solution is empty : ",mdl.solution.is_empty())

print("obj : ",mdl.solution.get_objective_value())

for v in mdl.iter_integer_vars():
    print(v," = ",v.solution_value)


solution is empty :  False
obj :  3800.0
nbBus40  =  6.0
nbBus30  =  2.0

But if add a constraint that I should not use more than 4 buses in total

mdl.add_constraint(nbbus40 + nbbus30 <= 4, 'nbbus')

then I get your error

    print("solution is empty : ",mdl.solution.is_empty())
AttributeError: 'NoneType' object has no attribute 'is_empty'

You should check why your model is not fasible

  • $\begingroup$ thanks for your reply. You're right. I'm trying to solve it. My model is a kind of assignment problem, but the tasks to be done are variable depending on the selected components (stated by variable Ymv). Would have any tips to model this problem in cplex? $\endgroup$ – campioni Mar 12 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.