@@ -247,14 +247,15 @@ cdef class LinearFunctionOrConstraint(ModuleElement):
247
247
::
248
248
249
249
sage: p = MixedIntegerLinearProgram()
250
+ sage: LF = p.linear_functions_parent()
250
251
sage: from sage.numerical.linear_functions import LinearFunction
251
- sage: p ({2 : 5, 3 : 2}) <= p ({2 : 3, 9 : 2})
252
+ sage: LF ({2 : 5, 3 : 2}) <= LF ({2 : 3, 9 : 2})
252
253
5*x_2 + 2*x_3 <= 3*x_2 + 2*x_9
253
254
254
- sage: p ({2 : 5, 3 : 2}) >= p ({2 : 3, 9 : 2})
255
+ sage: LF ({2 : 5, 3 : 2}) >= LF ({2 : 3, 9 : 2})
255
256
3*x_2 + 2*x_9 <= 5*x_2 + 2*x_3
256
257
257
- sage: p ({2 : 5, 3 : 2}) == p ({2 : 3, 9 : 2})
258
+ sage: LF ({2 : 5, 3 : 2}) == LF ({2 : 3, 9 : 2})
258
259
5*x_2 + 2*x_3 == 3*x_2 + 2*x_9
259
260
260
261
We can chain multiple (in)equalities::
@@ -304,8 +305,9 @@ cdef class LinearFunctionOrConstraint(ModuleElement):
304
305
TESTS::
305
306
306
307
sage: p.<x> = MixedIntegerLinearProgram()
308
+ sage: LF = p.linear_functions_parent()
307
309
sage: cm = sage.structure.element.get_coercion_model()
308
- sage: cm.explain(10, p (1), operator.le)
310
+ sage: cm.explain(10, LF (1), operator.le)
309
311
Coercion on left operand via
310
312
Conversion map:
311
313
From: Integer Ring
@@ -455,7 +457,8 @@ cdef class LinearFunctionOrConstraint(ModuleElement):
455
457
EXAMPLES::
456
458
457
459
sage: p = MixedIntegerLinearProgram( )
458
- sage: f = p( {2 : 5, 3 : 2})
460
+ sage: LF = p. linear_functions_parent( )
461
+ sage: f = LF( {2 : 5, 3 : 2})
459
462
sage: f. __hash__( ) # random output
460
463
103987752
461
464
sage: d = {}
@@ -471,7 +474,8 @@ cdef class LinearFunctionOrConstraint(ModuleElement):
471
474
EXAMPLES::
472
475
473
476
sage: p = MixedIntegerLinearProgram()
474
- sage: f = p({2 : 5, 3 : 2})
477
+ sage: LF = p.linear_functions_parent()
478
+ sage: f = LF({2 : 5, 3 : 2})
475
479
sage: cmp(f, f)
476
480
0
477
481
sage: abs(cmp(f, f+0)) # since we are comparing by id()
@@ -665,6 +669,7 @@ cdef class LinearFunctionsParent_class(Parent):
665
669
sage: LF._element_constructor_(123)
666
670
123
667
671
sage: p(123) # indirect doctest
672
+ doctest:...: DeprecationWarning: ...
668
673
123
669
674
sage: type(_)
670
675
<type 'sage.numerical.linear_functions.LinearFunction'>
@@ -749,19 +754,13 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
749
754
750
755
You should never instantiate :class:`LinearFunction`
751
756
manually. Use the element constructor in the parent
752
- instead. For convenience, you can also call the
753
- :class:`MixedIntegerLinearProgram` instance directly.
757
+ instead.
754
758
755
759
EXAMPLES:
756
760
757
761
For example, do this::
758
762
759
763
sage: p = MixedIntegerLinearProgram( )
760
- sage: p( {0 : 1, 3 : -8})
761
- x_0 - 8* x_3
762
-
763
- or this::
764
-
765
764
sage: parent = p. linear_functions_parent( )
766
765
sage: parent( {0 : 1, 3 : -8})
767
766
x_0 - 8* x_3
@@ -787,13 +786,15 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
787
786
With a dictionary::
788
787
789
788
sage: p = MixedIntegerLinearProgram( )
790
- sage: p( {0 : 1, 3 : -8})
789
+ sage: LF = p. linear_functions_parent( )
790
+ sage: LF( {0 : 1, 3 : -8})
791
791
x_0 - 8* x_3
792
792
793
793
Using the constructor with a numerical value::
794
794
795
795
sage: p = MixedIntegerLinearProgram( )
796
- sage: p( 25)
796
+ sage: LF = p. linear_functions_parent( )
797
+ sage: LF( 25)
797
798
25
798
799
"""
799
800
ModuleElement.__init__ (self , parent)
@@ -840,7 +841,8 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
840
841
EXAMPLE::
841
842
842
843
sage: p = MixedIntegerLinearProgram( )
843
- sage: lf = p( {0 : 1, 3 : -8})
844
+ sage: LF = p. linear_functions_parent( )
845
+ sage: lf = LF( {0 : 1, 3 : -8})
844
846
sage: lf. dict( )
845
847
{0: 1. 0, 3: -8. 0}
846
848
"""
@@ -912,7 +914,8 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
912
914
EXAMPLE::
913
915
914
916
sage: p = MixedIntegerLinearProgram( )
915
- sage: p( {0 : 1, 3 : -8}) + p( {2 : 5, 3 : 2}) - 16
917
+ sage: LF = p. linear_functions_parent( )
918
+ sage: LF( {0 : 1, 3 : -8}) + LF( {2 : 5, 3 : 2}) - 16
916
919
-16 + x_0 + 5* x_2 - 6* x_3
917
920
"""
918
921
e = dict (self ._f)
@@ -928,7 +931,8 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
928
931
EXAMPLE::
929
932
930
933
sage: p = MixedIntegerLinearProgram( )
931
- sage: - p( {0 : 1, 3 : -8})
934
+ sage: LF = p. linear_functions_parent( )
935
+ sage: - LF( {0 : 1, 3 : -8})
932
936
-1* x_0 + 8* x_3
933
937
"""
934
938
P = self .parent()
@@ -941,9 +945,10 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
941
945
EXAMPLE::
942
946
943
947
sage: p = MixedIntegerLinearProgram( )
944
- sage: p( {2 : 5, 3 : 2}) - 3
948
+ sage: LF = p. linear_functions_parent( )
949
+ sage: LF( {2 : 5, 3 : 2}) - 3
945
950
-3 + 5* x_2 + 2* x_3
946
- sage: p ( {0 : 1, 3 : -8}) - p ( {2 : 5, 3 : 2}) - 16
951
+ sage: LF ( {0 : 1, 3 : -8}) - LF ( {2 : 5, 3 : 2}) - 16
947
952
-16 + x_0 - 5* x_2 - 10* x_3
948
953
"""
949
954
e = dict (self ._f)
@@ -959,7 +964,8 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
959
964
EXAMPLE::
960
965
961
966
sage: p = MixedIntegerLinearProgram( )
962
- sage: p( {2 : 5, 3 : 2}) * 3
967
+ sage: LF = p. linear_functions_parent( )
968
+ sage: LF( {2 : 5, 3 : 2}) * 3
963
969
15* x_2 + 6* x_3
964
970
"""
965
971
P = self .parent()
@@ -972,7 +978,8 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
972
978
EXAMPLE::
973
979
974
980
sage: p = MixedIntegerLinearProgram( )
975
- sage: 3 * p( {2 : 5, 3 : 2})
981
+ sage: LF = p. linear_functions_parent( )
982
+ sage: 3 * LF( {2 : 5, 3 : 2})
976
983
15* x_2 + 6* x_3
977
984
"""
978
985
return self ._rmul_(b)
@@ -1094,10 +1101,12 @@ cdef class LinearFunction(LinearFunctionOrConstraint):
1094
1101
EXAMPLE::
1095
1102
1096
1103
sage: p = MixedIntegerLinearProgram( solver='GLPK')
1097
- sage: p( {-1: -15, 2 : -5. 1, 3 : 2/3})
1104
+ sage: LF = p. linear_functions_parent( )
1105
+ sage: LF( {-1: -15, 2 : -5. 1, 3 : 2/3})
1098
1106
-15 - 5. 1* x_2 + 0. 666666666667* x_3
1099
1107
sage: p = MixedIntegerLinearProgram( solver='ppl')
1100
- sage: p( {-1: -15, 2 : -5. 1, 3 : 2/3})
1108
+ sage: LF = p. linear_functions_parent( )
1109
+ sage: LF( {-1: -15, 2 : -5. 1, 3 : 2/3})
1101
1110
-15 - 51/10* x_2 + 2/3* x_3
1102
1111
"""
1103
1112
cdef dict d = dict (self ._f)
0 commit comments