Division Objective function in Pyscipopt
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to maximize the division of two quantities in PySCIPOpt.
Since it is a division of two linear metrics, it becomes a nonlinear optimization.
My code is somewhat like this:
model = Model()
x={}
for i in range(0,len(data)):
x[i] = model.addVar(vtype = 'B',name = 'x(%s)'%i)
data['Index'] = range(0,len(data))
profit = 0
volume = 0
for index in data['Index']:
profit += x[index] * data['Predicted.Profit'][index]
volume += x[index] * data['Predicted.Liters.Sold'][index]
model.setObjective(profit/volume,"maximize")
As soon as I hit the setObjective
command, my kernel gets busy for more than 20 minutes and just keeps working. I want to know is there something wrong with my definition of Objective function? Could I be doing something else? Something more efficient?
By the way, my dataset's shape is 178848x36
edit
The function ran after twenty minutes! But gave an error saying : AssertionError: given coefficients are neither Expr or number but ProdExpr
How do i Bypass this error? Since I wish to optimize the division of decisionVariables! As well as make this objective function declaration more efficient?
Edit2
Is there a way to cast ProdExpr as Expr??
python division nonlinear-optimization scip
add a comment |
I am trying to maximize the division of two quantities in PySCIPOpt.
Since it is a division of two linear metrics, it becomes a nonlinear optimization.
My code is somewhat like this:
model = Model()
x={}
for i in range(0,len(data)):
x[i] = model.addVar(vtype = 'B',name = 'x(%s)'%i)
data['Index'] = range(0,len(data))
profit = 0
volume = 0
for index in data['Index']:
profit += x[index] * data['Predicted.Profit'][index]
volume += x[index] * data['Predicted.Liters.Sold'][index]
model.setObjective(profit/volume,"maximize")
As soon as I hit the setObjective
command, my kernel gets busy for more than 20 minutes and just keeps working. I want to know is there something wrong with my definition of Objective function? Could I be doing something else? Something more efficient?
By the way, my dataset's shape is 178848x36
edit
The function ran after twenty minutes! But gave an error saying : AssertionError: given coefficients are neither Expr or number but ProdExpr
How do i Bypass this error? Since I wish to optimize the division of decisionVariables! As well as make this objective function declaration more efficient?
Edit2
Is there a way to cast ProdExpr as Expr??
python division nonlinear-optimization scip
@mattmitten any insights??
– linearprogrammer
Nov 25 '18 at 8:20
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
– mattmilten
Nov 25 '18 at 13:41
Please don't forget to accept my answer if it is sufficient.
– mattmilten
Nov 26 '18 at 11:06
add a comment |
I am trying to maximize the division of two quantities in PySCIPOpt.
Since it is a division of two linear metrics, it becomes a nonlinear optimization.
My code is somewhat like this:
model = Model()
x={}
for i in range(0,len(data)):
x[i] = model.addVar(vtype = 'B',name = 'x(%s)'%i)
data['Index'] = range(0,len(data))
profit = 0
volume = 0
for index in data['Index']:
profit += x[index] * data['Predicted.Profit'][index]
volume += x[index] * data['Predicted.Liters.Sold'][index]
model.setObjective(profit/volume,"maximize")
As soon as I hit the setObjective
command, my kernel gets busy for more than 20 minutes and just keeps working. I want to know is there something wrong with my definition of Objective function? Could I be doing something else? Something more efficient?
By the way, my dataset's shape is 178848x36
edit
The function ran after twenty minutes! But gave an error saying : AssertionError: given coefficients are neither Expr or number but ProdExpr
How do i Bypass this error? Since I wish to optimize the division of decisionVariables! As well as make this objective function declaration more efficient?
Edit2
Is there a way to cast ProdExpr as Expr??
python division nonlinear-optimization scip
I am trying to maximize the division of two quantities in PySCIPOpt.
Since it is a division of two linear metrics, it becomes a nonlinear optimization.
My code is somewhat like this:
model = Model()
x={}
for i in range(0,len(data)):
x[i] = model.addVar(vtype = 'B',name = 'x(%s)'%i)
data['Index'] = range(0,len(data))
profit = 0
volume = 0
for index in data['Index']:
profit += x[index] * data['Predicted.Profit'][index]
volume += x[index] * data['Predicted.Liters.Sold'][index]
model.setObjective(profit/volume,"maximize")
As soon as I hit the setObjective
command, my kernel gets busy for more than 20 minutes and just keeps working. I want to know is there something wrong with my definition of Objective function? Could I be doing something else? Something more efficient?
By the way, my dataset's shape is 178848x36
edit
The function ran after twenty minutes! But gave an error saying : AssertionError: given coefficients are neither Expr or number but ProdExpr
How do i Bypass this error? Since I wish to optimize the division of decisionVariables! As well as make this objective function declaration more efficient?
Edit2
Is there a way to cast ProdExpr as Expr??
python division nonlinear-optimization scip
python division nonlinear-optimization scip
edited Nov 24 '18 at 12:54
linearprogrammer
asked Nov 24 '18 at 12:12
linearprogrammerlinearprogrammer
156
156
@mattmitten any insights??
– linearprogrammer
Nov 25 '18 at 8:20
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
– mattmilten
Nov 25 '18 at 13:41
Please don't forget to accept my answer if it is sufficient.
– mattmilten
Nov 26 '18 at 11:06
add a comment |
@mattmitten any insights??
– linearprogrammer
Nov 25 '18 at 8:20
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
– mattmilten
Nov 25 '18 at 13:41
Please don't forget to accept my answer if it is sufficient.
– mattmilten
Nov 26 '18 at 11:06
@mattmitten any insights??
– linearprogrammer
Nov 25 '18 at 8:20
@mattmitten any insights??
– linearprogrammer
Nov 25 '18 at 8:20
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
– mattmilten
Nov 25 '18 at 13:41
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
– mattmilten
Nov 25 '18 at 13:41
Please don't forget to accept my answer if it is sufficient.
– mattmilten
Nov 26 '18 at 11:06
Please don't forget to accept my answer if it is sufficient.
– mattmilten
Nov 26 '18 at 11:06
add a comment |
1 Answer
1
active
oldest
votes
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. For PySCIPOpt, you need to do that step manually so avoid the creation of new variables and constraints behind the user's back. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
While introduce these steps to my code, I have one more question for you. In your experience, Can SCIP converge into a solution for a nonlinear problem with 200k integer decision variables?
– linearprogrammer
Nov 26 '18 at 10:49
Impossible to say. You have to give it a try. If it doesn't terminate but produces good enough solutions, you might want to set a gap limit.
– mattmilten
Nov 26 '18 at 11:05
By gap limit, do you mean the number of iterations?
– linearprogrammer
Nov 26 '18 at 11:25
No, I mean the gap limit as defined here: scip.zib.de/doc/html/FAQ.php#gapdefinition . Can be set withsetParam('limits/gap', <value>)
.
– mattmilten
Nov 26 '18 at 11:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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
},
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%2fstackoverflow.com%2fquestions%2f53458021%2fdivision-objective-function-in-pyscipopt%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
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. For PySCIPOpt, you need to do that step manually so avoid the creation of new variables and constraints behind the user's back. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
While introduce these steps to my code, I have one more question for you. In your experience, Can SCIP converge into a solution for a nonlinear problem with 200k integer decision variables?
– linearprogrammer
Nov 26 '18 at 10:49
Impossible to say. You have to give it a try. If it doesn't terminate but produces good enough solutions, you might want to set a gap limit.
– mattmilten
Nov 26 '18 at 11:05
By gap limit, do you mean the number of iterations?
– linearprogrammer
Nov 26 '18 at 11:25
No, I mean the gap limit as defined here: scip.zib.de/doc/html/FAQ.php#gapdefinition . Can be set withsetParam('limits/gap', <value>)
.
– mattmilten
Nov 26 '18 at 11:31
add a comment |
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. For PySCIPOpt, you need to do that step manually so avoid the creation of new variables and constraints behind the user's back. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
While introduce these steps to my code, I have one more question for you. In your experience, Can SCIP converge into a solution for a nonlinear problem with 200k integer decision variables?
– linearprogrammer
Nov 26 '18 at 10:49
Impossible to say. You have to give it a try. If it doesn't terminate but produces good enough solutions, you might want to set a gap limit.
– mattmilten
Nov 26 '18 at 11:05
By gap limit, do you mean the number of iterations?
– linearprogrammer
Nov 26 '18 at 11:25
No, I mean the gap limit as defined here: scip.zib.de/doc/html/FAQ.php#gapdefinition . Can be set withsetParam('limits/gap', <value>)
.
– mattmilten
Nov 26 '18 at 11:31
add a comment |
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. For PySCIPOpt, you need to do that step manually so avoid the creation of new variables and constraints behind the user's back. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. For PySCIPOpt, you need to do that step manually so avoid the creation of new variables and constraints behind the user's back. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
answered Nov 25 '18 at 13:44
mattmiltenmattmilten
2,33212043
2,33212043
While introduce these steps to my code, I have one more question for you. In your experience, Can SCIP converge into a solution for a nonlinear problem with 200k integer decision variables?
– linearprogrammer
Nov 26 '18 at 10:49
Impossible to say. You have to give it a try. If it doesn't terminate but produces good enough solutions, you might want to set a gap limit.
– mattmilten
Nov 26 '18 at 11:05
By gap limit, do you mean the number of iterations?
– linearprogrammer
Nov 26 '18 at 11:25
No, I mean the gap limit as defined here: scip.zib.de/doc/html/FAQ.php#gapdefinition . Can be set withsetParam('limits/gap', <value>)
.
– mattmilten
Nov 26 '18 at 11:31
add a comment |
While introduce these steps to my code, I have one more question for you. In your experience, Can SCIP converge into a solution for a nonlinear problem with 200k integer decision variables?
– linearprogrammer
Nov 26 '18 at 10:49
Impossible to say. You have to give it a try. If it doesn't terminate but produces good enough solutions, you might want to set a gap limit.
– mattmilten
Nov 26 '18 at 11:05
By gap limit, do you mean the number of iterations?
– linearprogrammer
Nov 26 '18 at 11:25
No, I mean the gap limit as defined here: scip.zib.de/doc/html/FAQ.php#gapdefinition . Can be set withsetParam('limits/gap', <value>)
.
– mattmilten
Nov 26 '18 at 11:31
While introduce these steps to my code, I have one more question for you. In your experience, Can SCIP converge into a solution for a nonlinear problem with 200k integer decision variables?
– linearprogrammer
Nov 26 '18 at 10:49
While introduce these steps to my code, I have one more question for you. In your experience, Can SCIP converge into a solution for a nonlinear problem with 200k integer decision variables?
– linearprogrammer
Nov 26 '18 at 10:49
Impossible to say. You have to give it a try. If it doesn't terminate but produces good enough solutions, you might want to set a gap limit.
– mattmilten
Nov 26 '18 at 11:05
Impossible to say. You have to give it a try. If it doesn't terminate but produces good enough solutions, you might want to set a gap limit.
– mattmilten
Nov 26 '18 at 11:05
By gap limit, do you mean the number of iterations?
– linearprogrammer
Nov 26 '18 at 11:25
By gap limit, do you mean the number of iterations?
– linearprogrammer
Nov 26 '18 at 11:25
No, I mean the gap limit as defined here: scip.zib.de/doc/html/FAQ.php#gapdefinition . Can be set with
setParam('limits/gap', <value>)
.– mattmilten
Nov 26 '18 at 11:31
No, I mean the gap limit as defined here: scip.zib.de/doc/html/FAQ.php#gapdefinition . Can be set with
setParam('limits/gap', <value>)
.– mattmilten
Nov 26 '18 at 11:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
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%2fstackoverflow.com%2fquestions%2f53458021%2fdivision-objective-function-in-pyscipopt%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
@mattmitten any insights??
– linearprogrammer
Nov 25 '18 at 8:20
In general, SCIP does not work with nonlinear objective functions. They are converted into a constraint and a new auxiliary variable works as objective. See here: github.com/SCIP-Interfaces/PySCIPOpt/issues/167
– mattmilten
Nov 25 '18 at 13:41
Please don't forget to accept my answer if it is sufficient.
– mattmilten
Nov 26 '18 at 11:06