Enforce constraints in nth visited node
$begingroup$
I have a problem similar to the tsp problem where :
$x_{i,j} in left{0,1right}$, is 1 if I visit node $j$ immediately after node $i$.
Now suppose that I need to enforce constraints for the n-th visited node, how would I do that in an efficient way, given the fact that I do not know a-priori which node I will visit first, second etc?
To elaborate, this would be part of my program:
$min sum_i sum_j c_{i,j} y_{i,j}$
st. $ ~ y_{i,j} le M ~ x_{i,j} ~~~ forall ~ i,j $
$ ~ y_{i,j} ge P_n~ x_{i,j} ~~~~ $ if $j$ is the n-th visited node
$ y in mathbb{R}_+ $
mixed-integer-programming
$endgroup$
add a comment |
$begingroup$
I have a problem similar to the tsp problem where :
$x_{i,j} in left{0,1right}$, is 1 if I visit node $j$ immediately after node $i$.
Now suppose that I need to enforce constraints for the n-th visited node, how would I do that in an efficient way, given the fact that I do not know a-priori which node I will visit first, second etc?
To elaborate, this would be part of my program:
$min sum_i sum_j c_{i,j} y_{i,j}$
st. $ ~ y_{i,j} le M ~ x_{i,j} ~~~ forall ~ i,j $
$ ~ y_{i,j} ge P_n~ x_{i,j} ~~~~ $ if $j$ is the n-th visited node
$ y in mathbb{R}_+ $
mixed-integer-programming
$endgroup$
add a comment |
$begingroup$
I have a problem similar to the tsp problem where :
$x_{i,j} in left{0,1right}$, is 1 if I visit node $j$ immediately after node $i$.
Now suppose that I need to enforce constraints for the n-th visited node, how would I do that in an efficient way, given the fact that I do not know a-priori which node I will visit first, second etc?
To elaborate, this would be part of my program:
$min sum_i sum_j c_{i,j} y_{i,j}$
st. $ ~ y_{i,j} le M ~ x_{i,j} ~~~ forall ~ i,j $
$ ~ y_{i,j} ge P_n~ x_{i,j} ~~~~ $ if $j$ is the n-th visited node
$ y in mathbb{R}_+ $
mixed-integer-programming
$endgroup$
I have a problem similar to the tsp problem where :
$x_{i,j} in left{0,1right}$, is 1 if I visit node $j$ immediately after node $i$.
Now suppose that I need to enforce constraints for the n-th visited node, how would I do that in an efficient way, given the fact that I do not know a-priori which node I will visit first, second etc?
To elaborate, this would be part of my program:
$min sum_i sum_j c_{i,j} y_{i,j}$
st. $ ~ y_{i,j} le M ~ x_{i,j} ~~~ forall ~ i,j $
$ ~ y_{i,j} ge P_n~ x_{i,j} ~~~~ $ if $j$ is the n-th visited node
$ y in mathbb{R}_+ $
mixed-integer-programming
mixed-integer-programming
asked Dec 19 '18 at 12:22
nikferrarinikferrari
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
The following may be more cumbersome than necessary, but I think it will work. (I do recommend checking it carefully, though.)
I'll assume that the starting point for your trip is a (possibly artificial) node with index 0, since you said you do not know which node is visited first. Start by adding the Miller-Tucker-Zemlin constraints. That adds (continuous) variables $u_i$ with domain $[1,dots,m]$ (where $m$ is the number of nodes). Fix $u_0=0$ and constraints$$u_i - u_j + 1le m(1-x_{ij})$$for all $i,j$ (including $i=0$ but excluding $j=0$ if this is a closed tour). The result is that $u_i$ will equal $k$ if and only if node $i$ is the $k$-th stop.
Now add binary variables $z_i,(i=1,dots,m)$ and add the constraint$$sum_{i=1}^m z_i=1.$$Variable $z_i$ will be 1 if and only if node $i$ is the $n$-th node visited. To enforce this, add$$u_j ge n z_j,forall j=1,dots,m$$(which ensures that $z_j=1$ implies that node $j$ is visited no earlier than the $n$-th stop) and$$u_ile n-1 + (m-n+1)(2-x_{ij}-z_j), forall i,jin{0,dots,m},jneq 0.$$This last constraint ensures that if $z_j=1$ and $x_{ij}=1$, $u_i le n-1$. Combine those and you have that $z_j=1$ implies $j$ is at least stop $n$ and its predecessor was at most stop $n-1$, so node $j$ must be stop $n$.
Now you just have to frame your conditional constraints using $z$ as the indicator of which stop is stop $n$.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3046325%2fenforce-constraints-in-nth-visited-node%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The following may be more cumbersome than necessary, but I think it will work. (I do recommend checking it carefully, though.)
I'll assume that the starting point for your trip is a (possibly artificial) node with index 0, since you said you do not know which node is visited first. Start by adding the Miller-Tucker-Zemlin constraints. That adds (continuous) variables $u_i$ with domain $[1,dots,m]$ (where $m$ is the number of nodes). Fix $u_0=0$ and constraints$$u_i - u_j + 1le m(1-x_{ij})$$for all $i,j$ (including $i=0$ but excluding $j=0$ if this is a closed tour). The result is that $u_i$ will equal $k$ if and only if node $i$ is the $k$-th stop.
Now add binary variables $z_i,(i=1,dots,m)$ and add the constraint$$sum_{i=1}^m z_i=1.$$Variable $z_i$ will be 1 if and only if node $i$ is the $n$-th node visited. To enforce this, add$$u_j ge n z_j,forall j=1,dots,m$$(which ensures that $z_j=1$ implies that node $j$ is visited no earlier than the $n$-th stop) and$$u_ile n-1 + (m-n+1)(2-x_{ij}-z_j), forall i,jin{0,dots,m},jneq 0.$$This last constraint ensures that if $z_j=1$ and $x_{ij}=1$, $u_i le n-1$. Combine those and you have that $z_j=1$ implies $j$ is at least stop $n$ and its predecessor was at most stop $n-1$, so node $j$ must be stop $n$.
Now you just have to frame your conditional constraints using $z$ as the indicator of which stop is stop $n$.
$endgroup$
add a comment |
$begingroup$
The following may be more cumbersome than necessary, but I think it will work. (I do recommend checking it carefully, though.)
I'll assume that the starting point for your trip is a (possibly artificial) node with index 0, since you said you do not know which node is visited first. Start by adding the Miller-Tucker-Zemlin constraints. That adds (continuous) variables $u_i$ with domain $[1,dots,m]$ (where $m$ is the number of nodes). Fix $u_0=0$ and constraints$$u_i - u_j + 1le m(1-x_{ij})$$for all $i,j$ (including $i=0$ but excluding $j=0$ if this is a closed tour). The result is that $u_i$ will equal $k$ if and only if node $i$ is the $k$-th stop.
Now add binary variables $z_i,(i=1,dots,m)$ and add the constraint$$sum_{i=1}^m z_i=1.$$Variable $z_i$ will be 1 if and only if node $i$ is the $n$-th node visited. To enforce this, add$$u_j ge n z_j,forall j=1,dots,m$$(which ensures that $z_j=1$ implies that node $j$ is visited no earlier than the $n$-th stop) and$$u_ile n-1 + (m-n+1)(2-x_{ij}-z_j), forall i,jin{0,dots,m},jneq 0.$$This last constraint ensures that if $z_j=1$ and $x_{ij}=1$, $u_i le n-1$. Combine those and you have that $z_j=1$ implies $j$ is at least stop $n$ and its predecessor was at most stop $n-1$, so node $j$ must be stop $n$.
Now you just have to frame your conditional constraints using $z$ as the indicator of which stop is stop $n$.
$endgroup$
add a comment |
$begingroup$
The following may be more cumbersome than necessary, but I think it will work. (I do recommend checking it carefully, though.)
I'll assume that the starting point for your trip is a (possibly artificial) node with index 0, since you said you do not know which node is visited first. Start by adding the Miller-Tucker-Zemlin constraints. That adds (continuous) variables $u_i$ with domain $[1,dots,m]$ (where $m$ is the number of nodes). Fix $u_0=0$ and constraints$$u_i - u_j + 1le m(1-x_{ij})$$for all $i,j$ (including $i=0$ but excluding $j=0$ if this is a closed tour). The result is that $u_i$ will equal $k$ if and only if node $i$ is the $k$-th stop.
Now add binary variables $z_i,(i=1,dots,m)$ and add the constraint$$sum_{i=1}^m z_i=1.$$Variable $z_i$ will be 1 if and only if node $i$ is the $n$-th node visited. To enforce this, add$$u_j ge n z_j,forall j=1,dots,m$$(which ensures that $z_j=1$ implies that node $j$ is visited no earlier than the $n$-th stop) and$$u_ile n-1 + (m-n+1)(2-x_{ij}-z_j), forall i,jin{0,dots,m},jneq 0.$$This last constraint ensures that if $z_j=1$ and $x_{ij}=1$, $u_i le n-1$. Combine those and you have that $z_j=1$ implies $j$ is at least stop $n$ and its predecessor was at most stop $n-1$, so node $j$ must be stop $n$.
Now you just have to frame your conditional constraints using $z$ as the indicator of which stop is stop $n$.
$endgroup$
The following may be more cumbersome than necessary, but I think it will work. (I do recommend checking it carefully, though.)
I'll assume that the starting point for your trip is a (possibly artificial) node with index 0, since you said you do not know which node is visited first. Start by adding the Miller-Tucker-Zemlin constraints. That adds (continuous) variables $u_i$ with domain $[1,dots,m]$ (where $m$ is the number of nodes). Fix $u_0=0$ and constraints$$u_i - u_j + 1le m(1-x_{ij})$$for all $i,j$ (including $i=0$ but excluding $j=0$ if this is a closed tour). The result is that $u_i$ will equal $k$ if and only if node $i$ is the $k$-th stop.
Now add binary variables $z_i,(i=1,dots,m)$ and add the constraint$$sum_{i=1}^m z_i=1.$$Variable $z_i$ will be 1 if and only if node $i$ is the $n$-th node visited. To enforce this, add$$u_j ge n z_j,forall j=1,dots,m$$(which ensures that $z_j=1$ implies that node $j$ is visited no earlier than the $n$-th stop) and$$u_ile n-1 + (m-n+1)(2-x_{ij}-z_j), forall i,jin{0,dots,m},jneq 0.$$This last constraint ensures that if $z_j=1$ and $x_{ij}=1$, $u_i le n-1$. Combine those and you have that $z_j=1$ implies $j$ is at least stop $n$ and its predecessor was at most stop $n-1$, so node $j$ must be stop $n$.
Now you just have to frame your conditional constraints using $z$ as the indicator of which stop is stop $n$.
answered Dec 20 '18 at 17:36
prubinprubin
1,490125
1,490125
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3046325%2fenforce-constraints-in-nth-visited-node%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown