Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
Sage Reference Manual: Numerical Optimization - Mirrors
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Numerical</strong> <strong>Optimization</strong>, Release 6.1.1<br />
sage: seq = Superincreasing(); seq<br />
An empty sequence.<br />
sage: seq = Superincreasing([1, 3, 6]); seq<br />
Super-increasing sequence of length 3<br />
sage: seq = Superincreasing(list([1, 2, 5, 21, 69, 189, 376, 919])); seq<br />
Super-increasing sequence of length 8<br />
is_superincreasing(seq=None)<br />
Determine whether or not seq is super-increasing.<br />
If seq=None then determine whether or not self is super-increasing.<br />
Let L = (a 1 , a 2 , a 3 , . . . , a n ) be a non-empty sequence of non-negative integers. Then L is said to be<br />
super-increasing if each a i is strictly greater than the sum of all previous values. That is, for each a i ∈ L<br />
the sequence L must satisfy the property<br />
∑i−1<br />
a i ><br />
k=1<br />
in order to be called a super-increasing sequence, where |L| ≥ 2. If L has exactly one element, then it is<br />
also defined to be a super-increasing sequence.<br />
INPUT:<br />
•seq – (default: None) a sequence to test<br />
OUTPUT:<br />
•If seq is None, then test self to determine whether or not it is super-increasing. In that case, return<br />
True if self is super-increasing; False otherwise.<br />
•If seq is not None, then test seq to determine whether or not it is super-increasing. Return True if<br />
seq is super-increasing; False otherwise.<br />
EXAMPLES:<br />
By definition, an empty sequence is not super-increasing:<br />
sage: from sage.numerical.knapsack import Superincreasing<br />
sage: Superincreasing().is_superincreasing([])<br />
False<br />
sage: Superincreasing().is_superincreasing()<br />
False<br />
sage: Superincreasing().is_superincreasing(tuple())<br />
False<br />
sage: Superincreasing().is_superincreasing(())<br />
False<br />
But here is an example of a super-increasing sequence:<br />
sage: L = [1, 2, 5, 21, 69, 189, 376, 919]<br />
sage: Superincreasing(L).is_superincreasing()<br />
True<br />
sage: L = (1, 2, 5, 21, 69, 189, 376, 919)<br />
sage: Superincreasing(L).is_superincreasing()<br />
True<br />
A super-increasing sequence can have zero as one of its elements:<br />
sage: L = [0, 1, 2, 4]<br />
sage: Superincreasing(L).is_superincreasing()<br />
True<br />
a k<br />
1.3. Super-increasing sequences 3