Ask Your Question
0

built in cython integration [beginner]

asked 2014-04-24 08:54:25 +0200

alejandroerickson gravatar image

When I run a built-in sage function that is defined as cython code, does it automatically run compiled code, or do I have to activate cython or something?

For example:

When I run the code

g = graphs.CompleteGraph(10)
g.traveling_salesman_problem()

in a notebook, without anything else, the second command contains instances of 'MixedIntegerLinearProgram', which appears to be a cdef from a pyx file. I've learnt today that this means it is written in cython, and I would like to confirm that if MixedIntegerLinearProgram gets called in g.traveling_salesman_problem(), that it does indeed run compiled code, and that I don't have to do anything special to activate it.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-04-24 09:54:32 +0200

kcrisman gravatar image

Yes.

You can find much of this out by trying

sage: g.traveling_salesman_problem??

to read the code. Note that in this case the function itself is in a .py (uncompiled, though in byte code I think) file. But the line

from sage.numerical.mip import MixedIntegerLinearProgram

indicates it uses MILP, and this is indeed a compiled file (as you can see by doing

sage: sage.numerical.mip.MixedIntegerLinearProgram?

where it indicates an .so file type.

However, in truth this calls an outside program (which you can set, e.g. CPLEX) to do the LP, so the compiled piece is less relevant than the fact that it uses a dedicated library to do the LP.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-04-24 08:54:25 +0200

Seen: 383 times

Last updated: Apr 24 '14