I'm trying to write this constraint in C++ and add it to my model (addLessOrEqual
):
$$\text{start}_{i}+\text{duration}_{i}\le\text{start}_{j}$$ for an $(i,j)$ arc of precedence.
Starts (IntVar
) and durations (int
) are part of an IntervalVar
. The problem is that I can't operate $+$ with IntVar
and Int
.
I'm using C++ and i get this error:
error: no match for ‘operator+’ (operand types are
‘__gnu_cxx::__alloc_traits<std::allocator<operations_research::sat::IntVar>
>::value_type {aka operations_research::sat::IntVar}’ and
‘__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}’)
cp_model.AddLessOrEqual(starts[j]+durations[j],starts[succ[j][s]])
What can I do to sum and get the expression? Is there another predefined constraint that does the same? Thanks!
AddLessOrEqual(LinearExpr(starts[j]).AddConstant(durations[j]), starts[succ[j][s]])
$\endgroup$