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 destinationReference request: how to model nonlinear regression?How to decide to write an objective function?How to handle real-world (soft) constraints in an optimization problem?Variable bounds in column generationHow to formulate this scheduling problem efficiently?What is this type of scheduling problem called?Labour Model - Resource Allocation based off Product ForecastsLinearize or approximate a square root constraintFinding minimum time for vehicle to reach to its destinationlinearization of objective function
UX writing: When to use "we"?
Find the missing country
How to get maximum number that newcount can hold?
What sort of solar system / atmospheric conditions, if any, would allow for a very cold planet that still receives plenty of light from its sun?
How to avoid a lengthy conversation with someone from the neighborhood I don't share interests with
Can I shorten this filter, that finds disk sizes over 100G?
Overprovisioning SSD on ubuntu. How? Ubuntu 19.04 Samsung SSD 860
A wiild aanimal, a cardinal direction, or a place by the water
Is there a general term for the items in a directory?
Went to a big 4 but got fired for underperformance in a year recently - Now every one thinks I'm pro - How to balance expectations?
Were there any unmanned expeditions to the moon that returned to Earth prior to Apollo?
Why are sugars in whole fruits not digested the same way sugars in juice are?
Why have both: BJT and FET transistors on IC output?
Partial Fractions: Why does this shortcut method work?
How do people drown while wearing a life jacket?
speaker impedence
Do the rules for the "Buying a Magic Item" downtime activity allow a character an opportunity to purchase the item later?
Gold Battle KoTH
A small reformulation of the Cosmological Argument
How does Rust's 128-bit integer `i128` work on a 64-bit system?
Can birds evolve without trees?
Is Norway in the Single Market?
What is time? Does it flow linearly? If so, how are we sure?
Why do my fried eggs start browning very fast?
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 destinationReference request: how to model nonlinear regression?How to decide to write an objective function?How to handle real-world (soft) constraints in an optimization problem?Variable bounds in column generationHow to formulate this scheduling problem efficiently?What is this type of scheduling problem called?Labour Model - Resource Allocation based off Product ForecastsLinearize or approximate a square root constraintFinding minimum time for vehicle to reach to its destinationlinearization of objective function
$begingroup$
$src_h,s$, $dst_h,s$, $ch_h,s$ are constants.
$a_h,s$, $x_i,j,s$ are binary variables.
$wt_h,s$ are continuous variables.
$mini.$
$$
sum_h in H sum_s in S (src_h,s + ch_h,s + dst_h,s + wt_h,s) times a_h,s
$$
$s.t.$
$$
forall i in H hspace0.3cm forall j in H hspace0.3cm forall s in S hspace0.3cm
$$
$$
wt_j,s geq ((src_i,s + ch_i,s+wt_i,s) - src_j,s) times x_i,j,s
$$
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 $src_i,s < src_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets.
linear-programming optimization
$endgroup$
add a comment |
$begingroup$
$src_h,s$, $dst_h,s$, $ch_h,s$ are constants.
$a_h,s$, $x_i,j,s$ are binary variables.
$wt_h,s$ are continuous variables.
$mini.$
$$
sum_h in H sum_s in S (src_h,s + ch_h,s + dst_h,s + wt_h,s) times a_h,s
$$
$s.t.$
$$
forall i in H hspace0.3cm forall j in H hspace0.3cm forall s in S hspace0.3cm
$$
$$
wt_j,s geq ((src_i,s + ch_i,s+wt_i,s) - src_j,s) times x_i,j,s
$$
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 $src_i,s < src_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets.
linear-programming optimization
$endgroup$
2
$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
8 hours ago
add a comment |
$begingroup$
$src_h,s$, $dst_h,s$, $ch_h,s$ are constants.
$a_h,s$, $x_i,j,s$ are binary variables.
$wt_h,s$ are continuous variables.
$mini.$
$$
sum_h in H sum_s in S (src_h,s + ch_h,s + dst_h,s + wt_h,s) times a_h,s
$$
$s.t.$
$$
forall i in H hspace0.3cm forall j in H hspace0.3cm forall s in S hspace0.3cm
$$
$$
wt_j,s geq ((src_i,s + ch_i,s+wt_i,s) - src_j,s) times x_i,j,s
$$
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 $src_i,s < src_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets.
linear-programming optimization
$endgroup$
$src_h,s$, $dst_h,s$, $ch_h,s$ are constants.
$a_h,s$, $x_i,j,s$ are binary variables.
$wt_h,s$ are continuous variables.
$mini.$
$$
sum_h in H sum_s in S (src_h,s + ch_h,s + dst_h,s + wt_h,s) times a_h,s
$$
$s.t.$
$$
forall i in H hspace0.3cm forall j in H hspace0.3cm forall s in S hspace0.3cm
$$
$$
wt_j,s geq ((src_i,s + ch_i,s+wt_i,s) - src_j,s) times x_i,j,s
$$
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 $src_i,s < src_j,s$ so how could I force $x_i,j,s = 1$ when this condition meets.
linear-programming optimization
linear-programming optimization
asked 9 hours ago
anoop yadavanoop yadav
1104 bronze badges
1104 bronze badges
2
$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
8 hours ago
add a comment |
2
$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
8 hours ago
2
2
$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
8 hours ago
$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
8 hours ago
add a comment |
1 Answer
1
active
oldest
votes
$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$
– dxb
8 hours ago
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$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$
– dxb
8 hours ago
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$
– dxb
8 hours ago
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 9 hours ago
SimonSimon
4721 silver badge13 bronze badges
4721 silver badge13 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$
– dxb
8 hours ago
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$
– dxb
8 hours ago
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$
– dxb
8 hours ago
$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$
– dxb
8 hours ago
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
2
$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
8 hours ago