py-cvxopt +DSDP

Mark Brethen mark.brethen at gmail.com
Tue Jul 29 18:48:38 PDT 2014


On Jul 28, 2014, at 11:56 AM, Jonathan Stickel <jjstickel at gmail.com> wrote:

>> Date: Sun, 27 Jul 2014 13:47:20 -0500
>> From: Mark Brethen <mark.brethen at gmail.com>
>> Subject: py-cvxopt +DSDP
>> 
>> py-cvxopt installed fine without any errors. However, when I tried running example code it reports:
>> 
>> Symbol not found: _ATL_cGetNB
>>  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cvxopt/lapack.so
>> 
>> Why does numpy and cvxopt use Apple's Accelerate framework by default and DSDP use macport's ATLAS?
>> 
>> Ticket #37097 describes issues building DSDP and other ports that depend on it (like cvxopt) due to linker issues with building against macports' ATLAS. I uninstalled DSDP and ATLAS and then patched DSDP as suggested in the ticket, but when I tried to install DSDP again it failed because it could not find Apple's Accelerate framework:
>> 
>> :info:build /usr/bin/clang -O3 -arch x86_64 -o maxcut maxcut.o /opt/local/var/macports/build/_Users_marbre_ports_math_DSDP/DSDP/work/DSDP5.8/lib/libdsdp.a -latlas -lm
>> :info:build ld: library not found for -latlas
>> :info:build clang: error: linker command failed with exit code 1 (use -v to see invocation)
>> 
>> I guess if you do this, you also need to provide the path to Apple's Accelerate framework?
> 
> 
> It seems that DSDP does not work with Apple's Accelerate framework,
> and hence if you use the +dsdp variant for py-cvxopt (not required),
> then you must use also use the +atlas variant for py-cvxopt. I suppose
> it is a bug that this conflict is not flagged in the py-cvxopt
> portfile. You could open a ticket for that part, if you like. In the
> meantime, just reinstall with consistent variants (I recommend using
> +atlas for all of the above, including numpy and scipy).
> 
> Regards,
> Jonathan

I was able to build DSDP with Apple's Accelerate.framework by patching 'make.include' at this line:

-LAPACKBLAS  = -llapack -lblas -lg2c -lm
+LAPACKBLAS  = -Wl,-framework -Wl,Accelerate -lm

and test that it works with the following python program:

 from cvxopt.base import matrix,spmatrix
from cvxopt import solvers

clst=[0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0]
hlst=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
      0.0, 0.0, 0.0, 0.0, 0.0, -1.0]
Gr=[0, 7, 14, 21, 28, 1, 5, 8]+[35]*5
Gc=[0, 1, 2, 3, 4, 5, 6, 7]+range(5)
Gmtr=spmatrix([1.0]*8+[-1.0]*5,Gr,Gc,(36,8))
c=-matrix(clst)
Gs=[-Gmtr]
h=[-matrix(hlst,(6,6))]
try:
  sol=solvers.sdp(c,Gs=Gs,hs=h,solver='dsdp')
  print 'optimal value: %.2f'%(1+(matrix(clst,(1,8))*sol['x'])[0],)
except:
  print 'could not use dsdp'
  sol=solvers.sdp(c,Gs=Gs,hs=h)
  print 'optimal value: %.2f'%(1+(matrix(clst,(1,8))*sol['x'])[0],)
  raise

which returns: 'optimal value: 2.00'


I'd suggest updating the port to use Apple's accelerated.framework by default (as does numpy and cvxopt).


Mark






More information about the macports-users mailing list