C++ issues

72 views
Skip to first unread message

Andrea Cassioli

unread,
May 3, 2012, 5:42:04 PM5/3/12
to TANGO Project - ALGENCAN
Dear all,
I have a silly problem I cannot sort out. I am calling ALGENCAN to
solve a box constrained problem from a C++ code. I am working on
Liinux using g++ and gfortran. I have modified the c interface that
comes with the ALGENCAN distribution to include my function/gradient
evaluation. All seems to be well set up and ALGENCAN starts without
problems. Now, the execution trace makes no sense! Two things got my
attention:

1- despite I pass iprint=0 and ncomp=6, I got

ALGENCAN PARAMETERS:
firstde = F
hptype = HAPPRO
innslvr = TN
sclsys = F
skipacc = T
lsssub = NONE
sclsub = NONE
rmfixv = T
slacks = F
scale = F
epsfeas = 1.0000D-08
epsopt = 1.0000D-06
iprint = 25769803776
ncomp = 171798691846

2- despite I set the return code for the evalf/evalg functions to be
zero, ALGENCAN always complains :

VEVALF WARNING: A non-null flag was returned.

3- the optimization process does not seems to work....

My impression is that there is some kind of integer alignment issue
between C++ and FORTRAN. Indeed all other real value appears to be
correct. Is there someone that has experience similar issues?


Best,
Andrea Cassioli

Ernesto G. Birgin

unread,
May 3, 2012, 6:35:02 PM5/3/12
to tango-...@googlegroups.com
Dear Andrea,

Thank you for your interest in Algencan.

The output you sent is what we call "preamble" and it shows some parameters of Algencan. It is printed for all values of iprint, unless you have an empty file named .silent (dot silent) in the same folder where you are running algencan.

Anyway, indeed there seems to be something wrong, since the printed value of parameter iprint is not 1 but a huge number (the same for parameter ncomp).

Did you try to run Algencan with the C/C++ interface provided by us (without further modifications)?

Regards,
Ernesto.

Andrea Cassioli

unread,
May 4, 2012, 10:02:35 AM5/4/12
to TANGO Project - ALGENCAN
Dear Ernesto,
indeed I figured out that the problem was related to the integer size.
I was compiling with the gfortran option

-fdefault-integer-8

which is required to let some other FORTRAN routine to work when
interfacing with C++. Now,I suspect that the macros used by ALGENCAN
to interface C and FORTRAN do a similar work and then that option is
not only useless but even harmful. What have been happening was that
the integer values were pushed as 64bit but ALGENCAN expected 32bit I
guess, or the other way round. Thus when ALGENCAN got the values from
the stack they were flipped, this being due to the integer alignment.
That was why a small value (even 0) could turn out to be a huge one.


Best,
Andrea

Wendel Melo

unread,
Oct 18, 2016, 4:12:46 PM10/18/16
to TANGO Project - ALGENCAN
Would not be possible, in future versions of Algencan, to add an extra parameter to avoid it printing this preamble in the screen? I believe it would be more elegant and efficient than check if a file called ".silent" exists. In my work, a have a very large sequence of problems to be solved. I think if Algencan has to check all times if there is this file in the current directory, I will have an unnecessary overhead about that. So, that is only a suggestion.

Best regards

Wendel Melo
Reply all
Reply to author
Forward
0 new messages