Originally posted by: salais
Hello,
I am working on implementing a TSPTW solver according to Pesant et al. in their paper "An exact constraint logic programming algorithm for the tsptw)
However in the model there exists the following constraint:
S[i] = j => S[epsilon
j] != beta[i] with the exception that e[j] != (N+1), for all i in Vo (1)
In the above equation, subscripts are represented by square brackets and the operator "=>" means "implies". The constraint functionality that I wish to accomplish would then be something like
// Subtour elimination
forall (i in Vo)
{
if (epsilon[S
i] != (N+1))
S[epsilon[S
i]] != beta[i];
}
Where epsilon and beta are arrays with the same length as Vo
This however does not work, since according to the documentation: "Conditions in if-else statements must be ground; that is, they must not contain decision variables."
Now this is very problematic since the model presented in the paper implies very strongly that the subscript j I need in eq. (1) to access the epsilon and beta vectors are in fact values of the dvar vector S.
Is there a way around this? Should I be modelling the "implies" operator in a different way? I also tried an alternative approech where i would write
// (4) Subtour elimination
forall (i in Vo : S[i] != (N+1))
{
S[epsilon[S
i]] != beta[i];
}
This yielded an error regarding the usage of decision variables.
My variables are
int beta
Vo;
int epsilon
Vo;
dvar int S
Vo;
Thanks in advance.
PS. How does one invoke the proper formatting for code on this forum?
#DecisionOptimization#OPLusingCPOptimizer