-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to run a demo because of bad alloc #168
Comments
One thing I can see by inspection is that your start[0] = 0;
start[1] = 1;
start[3] = 3;
start[4] = 4; |
Dear Ted,
thanks for the reply.
Could you please explain what is than this "start" variable used for?
Perhaps given my example, what these indexes values
are referring to?
Thanks so much,
V.
…On Thu, 4 Jul 2019 at 17:03, Ted Ralphs ***@***.***> wrote:
One thing I can see by inspection is that your start array is wrong. It
should be
start[0] = 0;
start[1] = 2;
start[2] = 4;
In general start[n_cols+1] should be equal to non_zeros.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#168?email_source=notifications&email_token=ACVO6GUHDB3JYB7U6BR7YWDP5YGLDA5CNFSM4H5SOKL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZHUQYY#issuecomment-508512355>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACVO6GXRCCDLFX4LZDVBQLDP5YGLDANCNFSM4H5SOKLQ>
.
|
Oops, sorry, I made a mistake in my response above that has now been corrected. The format used here is what is called Compressed Sparse Column format. It is explained in more detail here: |
I cannot find the reference where to read this compressed sparse form.
Could you send it again?
…On Sat, Jul 6, 2019, 4:39 AM Ted Ralphs ***@***.***> wrote:
Oops, sorry, I made a mistake in my response above that has now been
corrected. The format used here is what is called Compressed Sparse Column
format. It is explained in more detail here:
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#168?email_source=notifications&email_token=ACVO6GSPLYHTIRVTO42E6STP6AAVNA5CNFSM4H5SOKL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKRAPI#issuecomment-508891197>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACVO6GXZ3Z4O2HHURE54ZZ3P6AAVNANCNFSM4H5SOKLQ>
.
|
For future references:
https://en.m.wikipedia.org/wiki/Sparse_matrix
I will try and will provide you my feedback
…On Sat, Jul 6, 2019, 10:35 AM Vincenzo Calabrò ***@***.***> wrote:
I cannot find the reference where to read this compressed sparse form.
Could you send it again?
On Sat, Jul 6, 2019, 4:39 AM Ted Ralphs ***@***.***> wrote:
> Oops, sorry, I made a mistake in my response above that has now been
> corrected. The format used here is what is called Compressed Sparse Column
> format. It is explained in more detail here:
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#168?email_source=notifications&email_token=ACVO6GSPLYHTIRVTO42E6STP6AAVNA5CNFSM4H5SOKL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKRAPI#issuecomment-508891197>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ACVO6GXZ3Z4O2HHURE54ZZ3P6AAVNANCNFSM4H5SOKLQ>
> .
>
|
Dear Ted,
referring to the same problem, after trying to set the sparse compressed
form (both cases RowMajor and ColMajor) I still cannot run this simple demo.
Could you give me an hint please?
V.
…On Sun, 7 Jul 2019 at 10:03, Vincenzo Calabrò ***@***.***> wrote:
For future references:
https://en.m.wikipedia.org/wiki/Sparse_matrix
I will try and will provide you my feedback
On Sat, Jul 6, 2019, 10:35 AM Vincenzo Calabrò ***@***.***>
wrote:
> I cannot find the reference where to read this compressed sparse form.
> Could you send it again?
>
> On Sat, Jul 6, 2019, 4:39 AM Ted Ralphs ***@***.***> wrote:
>
>> Oops, sorry, I made a mistake in my response above that has now been
>> corrected. The format used here is what is called Compressed Sparse Column
>> format. It is explained in more detail here:
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub
>> <#168?email_source=notifications&email_token=ACVO6GSPLYHTIRVTO42E6STP6AAVNA5CNFSM4H5SOKL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKRAPI#issuecomment-508891197>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/ACVO6GXZ3Z4O2HHURE54ZZ3P6AAVNANCNFSM4H5SOKLQ>
>> .
>>
>
|
I can't tell you anything from just the fact that it does not work, especially not without seeing your (modified) code. This could be for a multitude of reasons. Please provide your code (preferably in a gist), the complete output and details, such as what version of SYMPHONY you are using, what compiler, what OS, how you built it, etc. If the code crashes, it would be ideal if you could send a backtrace. Please help me to help you. |
Dear Ted,
Thanks for the reply. I did attach the source code testing row major and
column major solution. Did you find it?
I am using ubuntu 18.04 (latest symphony official ubuntu package is 5.6.16).
The code quit with a bad alloc exception.
I cannot debug inside the symphony code to understand what's is going on.
I am using qtcreator as IDE, but the provided cose should work fine with
just standard libraries and g++.
What additional information do you need?
Please let me know if you need more specific data or release version or
perhaps if I should send the file once again.
Just in case you cannot access the attachment here a link for you:
https://drive.google.com/file/d/0B3L21s_d75NtcVRJQ1ZHMUloZ2VuRE1zb19xSzJqa1NfWExj/view?usp=drivesdk
Thanks for you support
V.
…On Mon, Jul 8, 2019, 5:22 PM Ted Ralphs ***@***.***> wrote:
I can't tell you anything from just the fact that it does not work,
especially not without seeing your (modified) code. This could be for a
multitude of reasons. Please provide your code (preferably in a gist), the
complete output and details, such as what version of SYMPHONY you are
using, what compiler, what OS, how you built it, etc. If the code crashes,
it would be ideal if you could send a backtrace. Please help me to help you.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#168?email_source=notifications&email_token=ACVO6GSFGXSOMYX3HI5V7DLP6NLSJA5CNFSM4H5SOKL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZNNXOA#issuecomment-509270968>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACVO6GQ7WTYV2I442Y2LDT3P6NLSJANCNFSM4H5SOKLQ>
.
|
Any suggestion so far? |
Sorry, I haven't had a chance to look at this. I will do so as soon as I can. |
Hi!
Please have a look into the following code:
`#include
/===========================================================================/
/* /
/ This file is part of the SYMPHONY MILP Solver Framework. /
/ /
/ SYMPHONY was jointly developed by Ted Ralphs ted@lehigh.edu and /
/ Laci Ladanyi ladanyi@us.ibm.com. /
/ /
/ The author of this file is Menal Guzelsoy /
/ /
/ (c) Copyright 2005-2019 Lehigh University. All Rights Reserved. /
/ /
/ This software is licensed under the Eclipse Public License. Please see /
/ accompanying file for terms. /
/ /
/===========================================================================*/
/-------------------------------------------------------------------------/
/* Matlab Code */
//clear all, close all, clc
//f = [1.3, 0, 2.5]
//A = [1.0, 2.0, 0.0; 0.0, 4.0, 5.0]
//b = [ 10; 10]
//lb = [1.5; 0.0; 1.0]
//ub = [inf; inf; inf]
//x = sdpvar(numel(f),1)
//C = [A*x<=b; lb<=x; x<=ub];
//sol = solvesdp(C, f*x)
//assert(~sol.problem)
//x = double(x)
//% f =
//%
//% 1.3000 0 2.5000
//%
//%
//% A =
//%
//% 1 2 0
//% 0 4 5
//%
//%
//% b =
//%
//% 10
//% 10
//%
//%
//% lb =
//%
//% 1.5000
//% 0
//% 1.0000
//%
//%
//% ub =
//%
//% Inf
//% Inf
//% Inf
//%
//% Linear matrix variable 3x1 (full, real, 3 variables)
//% Coeffiecient range: 1 to 1
//% * 0: obj = 1.800000000e+01 infeas = 0.000e+00 (0)
//% * 2: obj = 4.450000000e+00 infeas = 0.000e+00 (0)
//%
//% sol =
//%
//% struct with fields:
//%
//% yalmipversion: '20181012'
//% yalmiptime: 0.3979
//% solvertime: 0.0011
//% info: 'Successfully solved (GLPK-GLPKMEX-CC)'
//% problem: 0
//%
//%
//% x =
//%
//% 1.5000
//% 1.2500
//% 1.0000
/-------------------------------------------------------------------------/
#include <coin/symphony.h>
#include
#include <malloc.h>
int demo_symphony(int argc, char* argv[]){
/* Create a SYMPHONY environment */
sym_environment *env = sym_open_environment();
int n_cols = 3; //number of columns
double * objective =
(double *) malloc(sizeof(double) * n_cols);//the objective coefficients
double * col_lb =
(double *) malloc(sizeof(double) * n_cols);//the column lower bounds
double * col_ub =
(double *) malloc(sizeof(double) * n_cols);//the column upper bounds
// f = [1.3, 0, 2.5]
objective[0] = 1.3;
objective[1] = 0.0;
objective[2] = 2.5;
//Define the variable lower/upper bounds.
// lb = [1.5; 0.0; 1.0];
// ub = [inf; inf; inf];
col_lb[0] = 1.5;
col_lb[1] = 0.0;
col_lb[2] = 1.0;
col_ub[0] = sym_get_infinity();
col_ub[1] = sym_get_infinity();
col_ub[2] = sym_get_infinity();
// A = [ 1.0, 2.0, 0.0;
// 0.0, 4.0, 5.0]
// b = [ 10; 10]
int n_rows = 2;
char * row_sense =
(char *) malloc (sizeof(char) * n_rows); //the row senses
double * row_rhs =
(double *) malloc (sizeof(double) * n_rows); //the row right-hand-sides
double * row_range = NULL; //the row ranges
row_sense[0] = 'L';
row_rhs[0] = 10;
row_sense[1] = 'L';
row_rhs[1] = 10;
/* Constraint matrix definitions */
int non_zeros = 4;
int * start = (int *) malloc (sizeof(int) * (n_cols + 1));
int * index = (int *) malloc (sizeof(int) * non_zeros);
double * value = (double *) malloc (sizeof(double) *non_zeros);
start[0] = 0;
start[1] = 3;
start[2] = 6;
index[0] = 0;
index[1] = 1;
index[2] = 1;
index[3] = 2;
value[0] = 1;
value[1] = 2;
value[2] = 4;
value[3] = 5;
//define the integer variables
char * int_vars = (char *) malloc (sizeof(char) * n_cols);
int_vars[0] = FALSE;
int_vars[1] = FALSE;
int_vars[2] = FALSE;
//load the problem to environment
sym_explicit_load_problem(env, n_cols, n_rows, start, index, value, col_lb,
col_ub, int_vars, objective, NULL, row_sense,
row_rhs, row_range, TRUE);
sym_solve(env);
//get, print the solution
double * solution = (double *) malloc (sizeof(double) * n_cols);
double objective_value = 0.0;
sym_get_col_solution(env, solution);
sym_get_obj_val(env, &objective_value);
printf("%s\n%s%f\n%s%f\n%s%f\n%s%f\n","The optimal solution is",
" x0 = ",solution[0],
" x1 = ",solution[1],
" x2 = ",solution[2],
" with objective value = ",objective_value);
//free the memory
sym_close_environment(env);
if(objective){free(objective);}
if(col_lb) {free(col_lb);}
if(col_ub) {free(col_ub);}
if(row_rhs) {free(row_rhs);}
if(row_sense){free(row_sense);}
if(row_range){free(row_range);}
if(index) {free(index);}
if(start) {free(start);}
if(value) {free(value);}
if(int_vars) {free(int_vars);}
if(solution) {free(solution);}
return 0;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
}
`
I cannot execute the code because of a bad alloc exception. I guess is due to the form of the sparse matrix of the constraints. Could you let me understand how to prepare the data? I didn't find proper examples or documentation to get rid of the problem and complete the execution of such a simple case.
Thanks so much
The text was updated successfully, but these errors were encountered: