ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 05 May 2012 00:34:45 +0200linear programming in cythonhttps://ask.sagemath.org/question/8952/linear-programming-in-cython/hi,
i am trying to speed up a sage code in cython and i am having difficulties with calling the linear programming routine.
my algorithm requires me to solve a large number of linear programs. currently, i am doing this in sage by calling MixedLinearProgram inside a loop and updating variables depending on the solution.
is there a way to call that program inside a cython function? i would need a cython program that accepts arrays as inputs, solves a linear program and outputs an array.
many thanks for your help
markusFri, 04 May 2012 22:27:38 +0200https://ask.sagemath.org/question/8952/linear-programming-in-cython/Answer by Volker Braun for <p>hi,
i am trying to speed up a sage code in cython and i am having difficulties with calling the linear programming routine. </p>
<p>my algorithm requires me to solve a large number of linear programs. currently, i am doing this in sage by calling MixedLinearProgram inside a loop and updating variables depending on the solution. </p>
<p>is there a way to call that program inside a cython function? i would need a cython program that accepts arrays as inputs, solves a linear program and outputs an array. </p>
<p>many thanks for your help
markus</p>
https://ask.sagemath.org/question/8952/linear-programming-in-cython/?answer=13543#post-id-13543Presumably you have lots of **relatively simple** linear programs. Have a look at the PPL Cython interface in `sage/libs/ppl.pyx`, and in particular [maximize()](http://www.sagemath.org/doc/reference/sage/libs/ppl.html#sage.libs.ppl.Polyhedron.maximize)Fri, 04 May 2012 23:17:53 +0200https://ask.sagemath.org/question/8952/linear-programming-in-cython/?answer=13543#post-id-13543Comment by markus for <p>Presumably you have lots of <strong>relatively simple</strong> linear programs. Have a look at the PPL Cython interface in <code>sage/libs/ppl.pyx</code>, and in particular <a href="http://www.sagemath.org/doc/reference/sage/libs/ppl.html#sage.libs.ppl.Polyhedron.maximize">maximize()</a></p>
https://ask.sagemath.org/question/8952/linear-programming-in-cython/?comment=19818#post-id-19818Thanks Volker! I think that is exactly what I need. I am new to Sage and Cython so it might take me a while but thanks for pointing me in the right direction.
Also, do you have feeling for what time saving I can expect relative to MixedIntegerLinearProgam?
MarkusSat, 05 May 2012 00:34:45 +0200https://ask.sagemath.org/question/8952/linear-programming-in-cython/?comment=19818#post-id-19818