Closed hongkai-dai closed 3 years ago
I have modified model.resize in master to better cope with a null matrix. However I would suggest you use - double obj[]={1,-2}; double lo[]={0,-1}; double up[]={2,4}; model.loadProblem(2,0,NULL,NULL,NULL,lo,up,obj,NULL,NULL);
John Forrest On 13/03/2021 01:09, Hongkai Dai wrote:
I created a simple linear program problem with no rows, but only column bounds (bounds on variables). When I try to solve the program I receive segfault. Here is my code
include "ClpSimplex.hpp"
int main() { ClpSimplex model; model.resize(0,2); model.setObjectiveCoefficient(0,1); model.setObjectiveCoefficient(1, -2); model.setColumnLower(0,0); model.setColumnUpper(0,2); model.setColumnLower(1, -1); model.setColumnUpper(1,4); model.primal(); return 0; }
However if I add one row, then the program runs fine
include "ClpSimplex.hpp"
int main() { ClpSimplex model; model.resize(0,2); model.setObjectiveCoefficient(0,1); model.setObjectiveCoefficient(1, -2); model.setColumnLower(0,0); model.setColumnUpper(0,2); model.setColumnLower(1, -1); model.setColumnUpper(1,4); int row_index[] = {0,1}; double row_val[] = {1.,3.}; model.addRow(2, row_index, row_val,2.,15.); model.primal(); return 0; }
What is the right way to solve a linear programming problem with no rows?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/coin-or/Clp/issues/178, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWJYHEVBJORKN5JIH4IQBDTDKUM3ANCNFSM4ZDHPVMQ.
Thanks a lot John! Using loadProblem solves the segfault!
Just curious, is "loadProblem" always preferable to addRows
? The documentation says "loadProblem" is used after presolve, does that mean in normal case we should still use "addRows" which would incur presolve?
I would always use loadProblem. It is most efficient if all data is passed in at one go as then all arrays are setup once with correct size.
If it is easier to build model by rows, I would still use loadProblem with zero rows and then addRows.
On 13/03/2021 17:52, Hongkai Dai wrote:
Thanks a lot John! Using loadProblem solves the segfault!
Just curious, is "loadProblem" always preferable to |addRows|? The documentation says "loadProblem" is used after presolve, does that mean in normal case we should still use "addRows" which would incur presolve?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/coin-or/Clp/issues/178#issuecomment-798697935, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWJYHE4HCJIH5H55HKO7RLTDOJ5LANCNFSM4ZDHPVMQ.
Thanks John. I changed to use loadProblem
in our code, it works nicely.
I created a simple linear program problem with no rows, but only column bounds (bounds on variables). When I try to solve the program I receive segfault. Here is my code
However if I add one row, then the program runs fine
What is the right way to solve a linear programming problem with no rows?