Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Numerical</strong> <strong>Optimization</strong>, Release 6.1.1<br />
•vertices – iterator of vertex labels (str). A label can be None.<br />
OUTPUT:<br />
Generated names of new vertices if there is at least one None value present in vertices. None otherwise.<br />
EXAMPLE:<br />
sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend<br />
sage: gbe = GLPKGraphBackend()<br />
sage: vertices = [None for i in range(3)]<br />
sage: gbe.add_vertices(vertices)<br />
[’0’, ’1’, ’2’]<br />
sage: gbe.add_vertices([’A’, ’B’, None])<br />
[’5’]<br />
sage: gbe.add_vertices([’A’, ’B’, ’C’])<br />
sage: gbe.vertices()<br />
[’0’, ’1’, ’2’, ’A’, ’B’, ’5’, ’C’]<br />
TESTS:<br />
sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend<br />
sage: gbe = GLPKGraphBackend()<br />
sage: gbe.add_vertices([None, None, None, ’1’])<br />
[’0’, ’2’, ’3’]<br />
cpp()<br />
Solves the critical path problem of a project network.<br />
OUTPUT:<br />
The length of the critical path of the network<br />
EXAMPLE:<br />
sage: from sage.numerical.backends.glpk_graph_backend import GLPKGraphBackend<br />
sage: gbe = GLPKGraphBackend()<br />
sage: gbe.add_vertices([None for i in range(3)])<br />
[’0’, ’1’, ’2’]<br />
sage: gbe.set_vertex_demand(’0’, 3)<br />
sage: gbe.set_vertex_demand(’1’, 1)<br />
sage: gbe.set_vertex_demand(’2’, 4)<br />
sage: a = gbe.add_edge(’0’, ’2’)<br />
sage: a = gbe.add_edge(’1’, ’2’)<br />
sage: gbe.cpp()<br />
7.0<br />
sage: v = gbe.get_vertex(’1’)<br />
sage: print 1, v["rhs"], v["es"], v["ls"] # abs tol 1e-6<br />
1 1.0 0.0 2.0<br />
delete_edge(u, v, params=None)<br />
Deletes an edge from the graph.<br />
If an edge does not exist it is ignored.<br />
INPUT:<br />
•u – The name (as str) of the tail vertex of the edge<br />
•v – The name (as str) of the tail vertex of the edge<br />
84 Chapter 5. LP Solver backends