How to add Binary Variable with condition in LPWhen to use indicator constraints versus big-M approaches in solving (mixed-)integer programsFinding minimum time for vehicle to reach to its destinationIn an integer program, how I can force a binary variable to equal 1 if some condition holds?How to linearize the product of a binary and a non-negative continuous variable?Reference request: how to model nonlinear regression?Simplest way to eliminate redundant constraints due to a new cutCan we replace a binary variable with a continuous variable using a quadratic equality constraint?Variable bounds in column generationProve that these linear programming problems are bounded by $O(k^1/2)$How to formulate this scheduling problem efficiently?Finding minimum time for vehicle to reach to its destinationLinearization of objective function
Are there liquid fueled rocket boosters having coaxial fuel/oxidizer tanks?
What would it take to get a message to another star?
Why does this Jet Provost strikemaster have a textured leading edge?
How to gracefully leave a company you helped start?
Rebuses around the home
Units of measurement, especially length, when body parts vary in size among races
Why aren't rainbows blurred-out into nothing after they are produced?
What's the relationship betweeen MS-DOS and XENIX?
List, map function based on a condition
Scam? Phone call from "Department of Social Security" asking me to call back
Telephone number in spoken words
How do I call a 6-digit Australian phone number with a US-based mobile phone?
What can I do to increase the amount of LEDs I can power with a pro micro?
Did Michelle Obama have a staff of 23; and Melania have a staff of 4?
Is it OK to draw different current from L1 and L2 on NEMA 14-50?
What is the farthest a camera can see?
How can I communicate my issues with a potential date's pushy behavior?
What is the hottest thing in the universe?
Help, I cannot decide when to start the story
What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?
Is there a word for returning to unpreparedness?
What modifiers are added to the attack and damage rolls of this unique longbow from Waterdeep: Dragon Heist?
How can I find an old paper when the usual methods fail?
Solving pricing problem heuristically in column generation algorithm for VRP
How to add Binary Variable with condition in LP
When to use indicator constraints versus big-M approaches in solving (mixed-)integer programsFinding minimum time for vehicle to reach to its destinationIn an integer program, how I can force a binary variable to equal 1 if some condition holds?How to linearize the product of a binary and a non-negative continuous variable?Reference request: how to model nonlinear regression?Simplest way to eliminate redundant constraints due to a new cutCan we replace a binary variable with a continuous variable using a quadratic equality constraint?Variable bounds in column generationProve that these linear programming problems are bounded by $O(k^1/2)$How to formulate this scheduling problem efficiently?Finding minimum time for vehicle to reach to its destinationLinearization of objective function
$begingroup$
Notation
$textsrc_h,s,textdst_h,s,textch_h,s$ are constants.
$a_h,s,x_i,j,s$ are binary variables.
$textwt_h,s$ are continuous variables.
Problem
beginalignmin.&qquadsum_h in Hsum_sin S(textsrc_h,s+textch_h,s+textdst_h,s+textwt_h,s)times a_h,s\texts.t.&qquadforall i,jin H,,forall sin S:textwt_j,sgeq((textsrc_i,s+textch_i,s+textwt_i,s)-textsrc_j,s)times x_i,j,sendalign
Now $x_i,j,s = 1$ only when vehicle $i$ charges before vehicle $j$. (Finding minimum time for vehicle to reach to its destination) for reference.
Vehicle $i$ charges before $j$ only when $textsrc_i,s < textsrc_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets?
linear-programming optimization
$endgroup$
add a comment |
$begingroup$
Notation
$textsrc_h,s,textdst_h,s,textch_h,s$ are constants.
$a_h,s,x_i,j,s$ are binary variables.
$textwt_h,s$ are continuous variables.
Problem
beginalignmin.&qquadsum_h in Hsum_sin S(textsrc_h,s+textch_h,s+textdst_h,s+textwt_h,s)times a_h,s\texts.t.&qquadforall i,jin H,,forall sin S:textwt_j,sgeq((textsrc_i,s+textch_i,s+textwt_i,s)-textsrc_j,s)times x_i,j,sendalign
Now $x_i,j,s = 1$ only when vehicle $i$ charges before vehicle $j$. (Finding minimum time for vehicle to reach to its destination) for reference.
Vehicle $i$ charges before $j$ only when $textsrc_i,s < textsrc_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets?
linear-programming optimization
$endgroup$
3
$begingroup$
If $src$ are constants, then you know in advance whether $i$ charges before $j$, and you can just force $x_ijs = 1$ in this case (via a constraint or via treating it like a constant) — or am I missing something?
$endgroup$
– LarrySnyder610♦
Aug 3 at 21:42
$begingroup$
yes, you are right.
$endgroup$
– anoop yadav
Aug 4 at 8:50
1
$begingroup$
In that case I will write it as an answer in case it is useful to future readers.
$endgroup$
– LarrySnyder610♦
Aug 5 at 0:41
add a comment |
$begingroup$
Notation
$textsrc_h,s,textdst_h,s,textch_h,s$ are constants.
$a_h,s,x_i,j,s$ are binary variables.
$textwt_h,s$ are continuous variables.
Problem
beginalignmin.&qquadsum_h in Hsum_sin S(textsrc_h,s+textch_h,s+textdst_h,s+textwt_h,s)times a_h,s\texts.t.&qquadforall i,jin H,,forall sin S:textwt_j,sgeq((textsrc_i,s+textch_i,s+textwt_i,s)-textsrc_j,s)times x_i,j,sendalign
Now $x_i,j,s = 1$ only when vehicle $i$ charges before vehicle $j$. (Finding minimum time for vehicle to reach to its destination) for reference.
Vehicle $i$ charges before $j$ only when $textsrc_i,s < textsrc_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets?
linear-programming optimization
$endgroup$
Notation
$textsrc_h,s,textdst_h,s,textch_h,s$ are constants.
$a_h,s,x_i,j,s$ are binary variables.
$textwt_h,s$ are continuous variables.
Problem
beginalignmin.&qquadsum_h in Hsum_sin S(textsrc_h,s+textch_h,s+textdst_h,s+textwt_h,s)times a_h,s\texts.t.&qquadforall i,jin H,,forall sin S:textwt_j,sgeq((textsrc_i,s+textch_i,s+textwt_i,s)-textsrc_j,s)times x_i,j,sendalign
Now $x_i,j,s = 1$ only when vehicle $i$ charges before vehicle $j$. (Finding minimum time for vehicle to reach to its destination) for reference.
Vehicle $i$ charges before $j$ only when $textsrc_i,s < textsrc_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets?
linear-programming optimization
linear-programming optimization
edited Aug 4 at 8:27
TheSimpliFire♦
1,9816 silver badges38 bronze badges
1,9816 silver badges38 bronze badges
asked Aug 3 at 21:18
anoop yadavanoop yadav
1325 bronze badges
1325 bronze badges
3
$begingroup$
If $src$ are constants, then you know in advance whether $i$ charges before $j$, and you can just force $x_ijs = 1$ in this case (via a constraint or via treating it like a constant) — or am I missing something?
$endgroup$
– LarrySnyder610♦
Aug 3 at 21:42
$begingroup$
yes, you are right.
$endgroup$
– anoop yadav
Aug 4 at 8:50
1
$begingroup$
In that case I will write it as an answer in case it is useful to future readers.
$endgroup$
– LarrySnyder610♦
Aug 5 at 0:41
add a comment |
3
$begingroup$
If $src$ are constants, then you know in advance whether $i$ charges before $j$, and you can just force $x_ijs = 1$ in this case (via a constraint or via treating it like a constant) — or am I missing something?
$endgroup$
– LarrySnyder610♦
Aug 3 at 21:42
$begingroup$
yes, you are right.
$endgroup$
– anoop yadav
Aug 4 at 8:50
1
$begingroup$
In that case I will write it as an answer in case it is useful to future readers.
$endgroup$
– LarrySnyder610♦
Aug 5 at 0:41
3
3
$begingroup$
If $src$ are constants, then you know in advance whether $i$ charges before $j$, and you can just force $x_ijs = 1$ in this case (via a constraint or via treating it like a constant) — or am I missing something?
$endgroup$
– LarrySnyder610♦
Aug 3 at 21:42
$begingroup$
If $src$ are constants, then you know in advance whether $i$ charges before $j$, and you can just force $x_ijs = 1$ in this case (via a constraint or via treating it like a constant) — or am I missing something?
$endgroup$
– LarrySnyder610♦
Aug 3 at 21:42
$begingroup$
yes, you are right.
$endgroup$
– anoop yadav
Aug 4 at 8:50
$begingroup$
yes, you are right.
$endgroup$
– anoop yadav
Aug 4 at 8:50
1
1
$begingroup$
In that case I will write it as an answer in case it is useful to future readers.
$endgroup$
– LarrySnyder610♦
Aug 5 at 0:41
$begingroup$
In that case I will write it as an answer in case it is useful to future readers.
$endgroup$
– LarrySnyder610♦
Aug 5 at 0:41
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Since the $textsrc$ are constants, you know in advance whether $i$ charges before $j$, and you can just force $x_ijs=1$ in this case (via a constraint or by treating it like a constant).
$endgroup$
add a comment |
$begingroup$
Add two indicator constraints:
- when $x_i,j,s = 1$, the condition must be true ($i$ charges before $j$)
- when $x_i,j,s = 0$, the condition must be false ($i$ charges after $j$)
Most commercial solvers have simple APIs that allow you to add indicator constraints directly, without reformulation. For example, here's the documentation for Gurobi's addGenConstrIndicator function.
$endgroup$
4
$begingroup$
Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/…
$endgroup$
– Dipayan Banerjee
Aug 3 at 21:44
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "700"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2for.stackexchange.com%2fquestions%2f1149%2fhow-to-add-binary-variable-with-condition-in-lp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Since the $textsrc$ are constants, you know in advance whether $i$ charges before $j$, and you can just force $x_ijs=1$ in this case (via a constraint or by treating it like a constant).
$endgroup$
add a comment |
$begingroup$
Since the $textsrc$ are constants, you know in advance whether $i$ charges before $j$, and you can just force $x_ijs=1$ in this case (via a constraint or by treating it like a constant).
$endgroup$
add a comment |
$begingroup$
Since the $textsrc$ are constants, you know in advance whether $i$ charges before $j$, and you can just force $x_ijs=1$ in this case (via a constraint or by treating it like a constant).
$endgroup$
Since the $textsrc$ are constants, you know in advance whether $i$ charges before $j$, and you can just force $x_ijs=1$ in this case (via a constraint or by treating it like a constant).
answered Aug 5 at 0:42
LarrySnyder610♦LarrySnyder610
5,58714 silver badges64 bronze badges
5,58714 silver badges64 bronze badges
add a comment |
add a comment |
$begingroup$
Add two indicator constraints:
- when $x_i,j,s = 1$, the condition must be true ($i$ charges before $j$)
- when $x_i,j,s = 0$, the condition must be false ($i$ charges after $j$)
Most commercial solvers have simple APIs that allow you to add indicator constraints directly, without reformulation. For example, here's the documentation for Gurobi's addGenConstrIndicator function.
$endgroup$
4
$begingroup$
Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/…
$endgroup$
– Dipayan Banerjee
Aug 3 at 21:44
add a comment |
$begingroup$
Add two indicator constraints:
- when $x_i,j,s = 1$, the condition must be true ($i$ charges before $j$)
- when $x_i,j,s = 0$, the condition must be false ($i$ charges after $j$)
Most commercial solvers have simple APIs that allow you to add indicator constraints directly, without reformulation. For example, here's the documentation for Gurobi's addGenConstrIndicator function.
$endgroup$
4
$begingroup$
Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/…
$endgroup$
– Dipayan Banerjee
Aug 3 at 21:44
add a comment |
$begingroup$
Add two indicator constraints:
- when $x_i,j,s = 1$, the condition must be true ($i$ charges before $j$)
- when $x_i,j,s = 0$, the condition must be false ($i$ charges after $j$)
Most commercial solvers have simple APIs that allow you to add indicator constraints directly, without reformulation. For example, here's the documentation for Gurobi's addGenConstrIndicator function.
$endgroup$
Add two indicator constraints:
- when $x_i,j,s = 1$, the condition must be true ($i$ charges before $j$)
- when $x_i,j,s = 0$, the condition must be false ($i$ charges after $j$)
Most commercial solvers have simple APIs that allow you to add indicator constraints directly, without reformulation. For example, here's the documentation for Gurobi's addGenConstrIndicator function.
answered Aug 3 at 21:29
SimonSimon
6522 silver badges13 bronze badges
6522 silver badges13 bronze badges
4
$begingroup$
Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/…
$endgroup$
– Dipayan Banerjee
Aug 3 at 21:44
add a comment |
4
$begingroup$
Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/…
$endgroup$
– Dipayan Banerjee
Aug 3 at 21:44
4
4
$begingroup$
Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/…
$endgroup$
– Dipayan Banerjee
Aug 3 at 21:44
$begingroup$
Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/…
$endgroup$
– Dipayan Banerjee
Aug 3 at 21:44
add a comment |
Thanks for contributing an answer to Operations Research 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%2for.stackexchange.com%2fquestions%2f1149%2fhow-to-add-binary-variable-with-condition-in-lp%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
3
$begingroup$
If $src$ are constants, then you know in advance whether $i$ charges before $j$, and you can just force $x_ijs = 1$ in this case (via a constraint or via treating it like a constant) — or am I missing something?
$endgroup$
– LarrySnyder610♦
Aug 3 at 21:42
$begingroup$
yes, you are right.
$endgroup$
– anoop yadav
Aug 4 at 8:50
1
$begingroup$
In that case I will write it as an answer in case it is useful to future readers.
$endgroup$
– LarrySnyder610♦
Aug 5 at 0:41