text:
# Abstract polytope

(Redirected from Abstract regular polytope)
A square pyramid and the associated abstract polytope.

In mathematics, an abstract polytope is an algebraic partially ordered set or poset which captures the combinatorial properties of a traditional polytope, but not any purely geometric properties such as angles, edge lengths, etc.

An ordinary geometric polytope is said to be a realization in some real N-dimensional space, typically Euclidean, of the corresponding abstract polytope.

The abstract definition allows some more general combinatorial structures than traditional definitions of a polytope, thus allowing many new objects that have no counterpart in traditional theory.

The term polytope is a generalisation of polygons and polyhedra into any number of dimensions.

## Introductory concepts

In Euclidean geometry, the six quadrilaterals illustrated are all different. Yet they have a common structure in the alternating chain of four vertices and four sides which gives them their name. They are said to be isomorphic or “structure preserving”.

This common structure may be represented in an underlying abstract polytope, a purely algebraic partially-ordered set which captures the pattern of connections or incidences between the various structural elements. The measurable properties of traditional polytopes such as angles, edge-lengths, skewness, straightness and convexity have no meaning for an abstract polytope.

What is true for traditional polytopes (also called classical or geometric polytopes) may not be so for abstract ones, and vice versa. For example, a traditional polytope is regular if all its facets and vertex figures are regular, but this is not necessarily so for an abstract polytope.[1]

#### Realisations

A traditional geometric polytope is said to be a realisation of the associated abstract polytope. A realisation is a mapping or injection of the abstract object into a real space, typically Euclidean, to construct a traditional polytope as a real geometric figure.

The six quadrilaterals shown are all distinct realisations of the abstract quadrilateral, each with different geometric properties. Some of them do not conform to traditional definitions of a quadrilateral and are said to be unfaithful realisations. A conventional polytope is a faithful realisation.

### Faces, ranks and ordering

In an abstract polytope, each structural element - vertex, edge, cell, etc. is associated with a corresponding member or element of the set. The term face often refers to any such element e.g. a vertex (0-face), edge (1-face) or a general k-face, and not just a polygonal 2-face.

The faces are ranked according to their associated real dimension: vertices have rank = 0, edges rank = 1 and so on.

Incident faces of different rank, for example a vertex F of an edge G, are ordered by the relation F < G. F is said to be a subface of G, or G has subface F.

F, G are said to be incident if either F = G or F < G or G < F. This usage of "incidence" also occurs in Finite geometry, although it differs from traditional geometry and some other areas of mathematics. For example in the square abcd, edges ab and bc are not abstractly incident (although they are both incident with vertex b).[citation needed]

A polytope is then defined as a set of faces P with an order relation <, and which satisfies certain additional axioms. Formally, P (with <) will be a (strict) partially ordered set, or poset.

### Least and greatest faces

Just as the number zero is necessary in mathematics, so also set theory requires an empty set which, technically, every set contains. In an abstract polytope this is known as the least or null face and is a subface of all the others. Since the least face is one level below the vertices or 0-faces, its rank is −1 and may be denoted as F−1. It is not usually realized.

There is also a single face of which all the others are subfaces. This is called the greatest face. In an n-dimensional polytope, the greatest face has rank = n and may be denoted as Fn. It is sometimes realized as the interior of the geometric figure.

These least and greatest faces are sometimes called improper faces, with all others being proper faces.

### A simple example

The faces of the abstract quadrilateral or square are shown in the table below:

Face type Rank (k) Count k-faces
Least −1 1 F−1
Vertex 0 4 a, b, c, d
Edge 1 4 W, X, Y, Z
Greatest 2 1 G

The relation < comprises a set of pairs, which here include

F−1<a, ... , F−1<X, ... , F−1<G, ... , b<Y, ... , c<G, ... , Z<G.

Order relations are transitive, i.e. F < G and G < H implies that F < H. Therefore, to specify the hierarchy of faces, it is not necessary to give every case of F < H, only the pairs where one is the successor of the other, i.e. where F < H and no G satisfies F < G < H.

The edges W, X, Y and Z are sometimes written as ab, ad, bc, and cd respectively, but such notation is not always appropriate.

All four edges are structurally similar and the same is true of the vertices. The figure therefore has the symmetries of a square and is usually referred to as the square.

### The Hasse diagram

The graph (left) and Hasse diagram of a quadrilateral, showing ranks (right)

Smaller posets, and polytopes in particular, are often best visualised in a Hasse diagram, as shown. By convention, faces of equal rank are placed on the same vertical level. Each "line" between faces, say F, G, indicates an ordering relation < such that F < G where F is below G in the diagram.

The Hasse diagram defines the unique poset and therefore fully captures the structure of the polytope. Isomorphic polytopes give rise to isomorphic Hasse diagrams, and vice versa. The same is not generally true for the graph representation of polytopes.

### Rank

The rank of a face F is defined as (m − 2), where m is the maximum number of faces in any chain (F', F", ... , F) satisfying F' < F" < ... < F. F' is always the least face, F−1.

The rank of an abstract polytope P is the maximum rank n of any face. It is always the rank of the greatest face Fn.

The rank of a face or polytope usually corresponds to the dimension of its counterpart in traditional theory.

For some ranks, their face-types are named in the following table.

Rank -1 0 1 2 3 ... n - 2 n - 1 n
Face Type Least Vertex Edge Cell Subfacet or ridge[2] Facet[2] Greatest

† Traditionally "face" has meant a rank 2 face or 2-face. In abstract theory the term "face" denotes a face of any rank.

### Flags

A flag is a maximal chain of faces, i.e. a (totally) ordered set Ψ of faces, each a subface of the next (if any), and such that Ψ is not a subset of any larger chain. Given any two distinct faces F, G in a flag, either F < G or F > G.

For example, {ø, a, ab, abc} is a flag in the triangle abc.

For a given polytope, all flags contain the same number of faces. Other posets do not, in general, satisfy this requirement.

### Sections

The graph (left) and Hasse Diagram of a triangular prism, showing a 1-section (red), and a 2-section (green).

Any subset P' of a poset P is a poset (with the same relation <, restricted to P').

In an abstract polytope, given any two faces F, H of P with FH, the set {G | FGH} is called a section of P, and denoted H/F. (In order theory, a section is called a closed interval of the poset and denoted [F, H].

For example, in the prism abcxyz (see diagram) the section xyz/ø (highlighted green) is the triangle

{ø, x, y, z, xy, xz, yz, xyz}.

A k-section is a section of rank k.

A polytope that is the subset of another polytope is not necessarily a section. In the diagram, the square abcd is a subset of the tetrahedron abcd, but is not a section of it.

P is thus a section of itself.

This concept of section does not have the same meaning as in traditional geometry.

#### Vertex figures

The vertex figure at a given vertex V is the (n−1)-section Fn/V, where Fn is the greatest face.

For example, in the triangle abc, the vertex figure at b, abc/b, is {b, ab, bc, abc}, which is a line segment. The vertex figures of a cube are triangles.

#### Connectedness

A poset P is connected if P has rank ≤ 1, or, given any two proper faces F and G, there is a sequence of proper faces

H1, H2, ... ,Hk

such that F = H1, G = Hk, and each Hi, i < k, is incident with its successor.

The above condition ensures that a pair of disjoint triangles abc and xyz is not a (single) polytope.

A poset P is strongly connected if every section of P (including P itself) is connected.

With this additional requirement, two pyramids that share just a vertex are also excluded. However, two square pyramids, for example, can, be "glued" at their square faces - giving an octahedron. The "common face" is not then a face of the octahedron.

## Formal definition

An abstract polytope is a partially ordered set, whose elements we call faces, satisfying the 4 axioms:

1. It has a least face and a greatest face.
2. All flags contain the same number of faces.
3. It is strongly connected.
4. Every 1-section is a line segment.

An n-polytope is a polytope of rank n.

### Notes

In the case of the null polytope, the least and greatest faces are the same single element.

Axiom 2 is equivalent to saying that the poset is a graded poset.

Given the other axioms, Axiom 3 is equivalent to strong flag-connectedness, which informally means:

For any section of the polytope (including the polytope itself), any flag can be changed into any other by changing just one face at a time.

Axiom 4 is known as the “diamond property”, since the Hasse Diagram of a line segment is diamond-shaped.

It can be shown from the axioms that every section is a polytope, and that Rank(G/F) = Rank(G) − Rank(F) − 1.

## The simplest polytopes

### Rank < 1

There is just one poset for each rank −1 and 0. These are, respectively, the null face and the point. These are not always considered to be valid abstract polytopes.

### Rank 1: the line segment

The graph (left) and Hasse Diagram of a line segment

There is only one polytope of rank 1, which is the line segment. It has a least face, just two 0-faces and a greatest face, for example {ø, a, b, ab}. It follows that the vertices a and b have rank 0, and that the greatest face ab, and therefore the poset, both have rank 1.

### Rank 2: polygons

For each p, 3 ≤ p < ${\displaystyle \infty }$, we have the (abstract equivalent of) the traditional polygon with p vertices and p edges, or a p-gon. For p = 3, 4, 5, ... we have the triangle, square, pentagon, ....

For p = 2, we have the digon, and p = ${\displaystyle \infty }$ we get the apeirogon.

#### The digon

The graph (left) and Hasse Diagram of a digon

A digon is a polygon with just 2 edges. Unlike any other polygon, both edges have the same two vertices. For this reason, it is degenerate in the Euclidean plane.

Faces are sometimes described using "vertex notation" - e.g. {ø, a, b, c, ab, ac, bc, abc} for the triangle abc. This method has the advantage of implying the < relation.

With the digon this vertex notation cannot be used. It is necessary to give the faces individual symbols and specify the subface pairs F < G.

Thus a digon is defined as a set {ø, a, b, E', E", G} with the relation < given by

{ø<a, ø<b, a<E', a<E", b<E', b<E", E'<G, E"<G}

where E' and E" are the two edges, and G the greatest face.

This need to identify each element of the polytope with a unique symbol apples to many other abstract polytopes and is therefore common practice.

A polytope can only be fully described using vertex notation if every face is incident with a unique set of vertices. A polytope having this property is said to be atomistic.

## Examples of higher rank

The set of j-faces (−1 ≤ jn) of a traditional n-polytope form an abstract n-polytope.

The concept of an abstract polytope is more general and also includes:

### Hosohedra and hosotopes

A hexagonal hosohedron, realized as a spherical polyhedron.

The digon is generalized by the hosohedron and higher dimensional hosotopes, which can all be realized as spherical polyhedra – they tessellate the sphere.

### Projective polytopes

The Hemicube may be derived from a cube by identifying opposite vertices, edges, and faces. It has 4 vertices, 6 edges, and 3 faces.

Four examples of non-traditional abstract polyhedra are the Hemicube (shown), Hemi-octahedron, Hemi-dodecahedron, and the Hemi-icosahedron. These are the projective counterparts of the Platonic solids, and can be realized as (globally) projective polyhedra – they tessellate the real projective plane.

The hemicube is another example of where vertex notation can not be used to define a polytope - all the 2-faces and the 3-face have the same vertex set.

## Duality

Every geometric polytope has a dual twin. Abstractly, the dual is the same polytope but with the ranking reversed in order: the Hasse diagram differs only in its annotations. In an n-polytope, each of the original k-faces maps to an (n − k − 1)-face in the dual. Thus, for example, the n-face maps to the (−1)-face. The dual of a dual is (isomorphic to) the original.

A polytope is self-dual if it is the same as, i.e. isomorphic to, its dual. Hence, the Hasse diagram of a self-dual polytope must be symmetrical about the horizontal axis half-way between the top and bottom. The square pyramid in the example above is self-dual.

The vertex figure at a vertex V is the dual of the facet to which V maps in the dual polytope.

## Abstract regular polytopes

Formally, an abstract polytope is defined to be "regular" if its automorphism group acts transitively on the set of its flags. In particular, any two k-faces F, G of an n-polytope are "the same", i.e. that there is an automorphism which maps F to G. When an abstract polytope is regular, its automorphism group is isomorphic to a quotient of a Coxeter group.

All polytopes of rank ≤ 2 are regular. The most famous regular polyhedra are the five Platonic solids. The hemicube (shown) is also regular.

Informally, for each rank k, this means that there is no way to distinguish any k-face from any other - the faces must be identical, and must have identical neighbors, and so forth. For example, a cube is regular because all the faces are squares, each square's vertices are attached to three squares, and each of these squares is attached to identical arrangements of other faces, edges and vertices, and so on.

This condition alone is sufficient to ensure that any regular abstract polytope has isomorphic regular (n−1)-faces and isomorphic regular vertex figures.

This is a weaker condition than regularity for traditional polytopes, in that it refers to the (combinatorial) automorphism group, not the (geometric) symmetry group. For example, any abstract polygon is regular, since angles, edge-lengths, edge curvature, skewness etc. don't exist for abstract polytopes.

There are several other weaker concepts, some not yet fully standardised, such as semi-regular, quasi-regular, uniform, chiral, and Archimedean that apply to polytopes that have some, but not all of their faces equivalent in each rank.

### An irregular example

An irregular polyhedron which has no automorphisms at all.

Given the amount of attention lavished on regular polytopes, one might almost think that all polytopes are regular. In reality, regular polytopes are just very special cases.

The simplest irregular polytope is the square pyramid, though this still has many symmetries.

An example of a polyhedron with no nontrivial symmetries is shown - no pair of vertices, edges, or 2-faces are "the same", as defined above. This is possibly the simplest such polytope.

## Realisation

A realisation of an abstract polytope is a collection of points in space (corresponding to the vertices of the polytope), together with the face structure induced on it by the polytope. For example the set of points {(0,0), (0,1), (1,0), (1,1)} is a realisation of the abstract square. It is not the only realisation, however - one could choose any set of four points in the target space.

If an abstract n-polytope is realized in n-dimensional space, such that the geometrical arrangement does not break any rules for traditional polytopes (such as curved faces, or ridges of zero size), then the realisation is said to be faithful. In general, only a restricted set of abstract polytopes of rank n may be realized faithfully in any given n-space. The characterisation of this effect is an outstanding problem.

For a regular abstract polytope, if the combinatorial automorphisms of the abstract polytope are realised by geometric symmetries then the geometric figure will be a regular polytope.

## The amalgamation problem and universal polytopes

An important question in the theory of abstract polytopes is the amalgamation problem. This is a series of questions such as

For given abstract polytopes K and L, are there any polytopes P whose facets are K and whose vertex figures are L ?
If so, are they all finite ?
What finite ones are there ?

For example, if K is the square, and L is the triangle, the answers to these questions are

Yes, there are polytopes P with square faces, joined three per vertex (that is, there are polytopes of type {4,3}).
Yes, they are all finite, specifically,
There is the cube, with six square faces, twelve edges and eight vertices, and the hemi-cube, with three faces, six edges and four vertices.

It is known that if the answer to the first question is 'Yes' for some regular K and L, then there is a unique polytope whose facets are K and whose vertex figures are L, called the universal polytope with these facets and vertex figures, which covers all other such polytopes. That is, suppose P is the universal polytope with facets K and vertex figures L. Then any other polytope Q with these facets and vertex figures can be written Q=P/N, where

• N is a subgroup of the automorphism group of P, and
• P/N is the collection of orbits of elements of P under the action of N, with the partial order induced by that of P.

Q=P/N is called a quotient of P, and we say P covers Q.

Given this fact, the search for polytopes with particular facets and vertex figures usually goes as follows:

1. Attempt to find the applicable universal polytope
2. Attempt to classify its quotients.

These two problems are, in general, very difficult.

Returning to the example above, if K is the square, and L is the triangle, the universal polytope {K,L} is the cube (also written {4,3}). The hemicube is the quotient {4,3}/N, where N is a group of symmetries (automorphisms) of the cube with just two elements - the identity, and the symmetry that maps each corner (or edge or face) to its opposite.

If L is, instead, also a square, the universal polytope {K,L} (that is, {4,4}) is the tessellation of the Euclidean plane by squares. This tessellation has infinitely many quotients with square faces, four per vertex, some regular and some not. Except for the universal polytope itself, they all correspond to various ways to tessellate either a torus or an infinitely long cylinder with squares.

### The 11-cell and the 57-cell

The 11-cell, discovered independently by H. S. M. Coxeter and Branko Grünbaum, is an abstract 4-polytope. Its facets are hemi-icosahedra. Since its facets are, topologically, projective planes instead of spheres, the 11-cell is not a tessellation of any manifold in the usual sense. Instead, the 11-cell is a locally projective polytope. The 11-cell is not only beautiful in the mathematical sense, it is also historically important as one of the first non-traditional abstract polytopes discovered. It is self-dual and universal: it is the only polytope with hemi-icosahedral facets and hemi-dodecahedral vertex figures.

The 57-cell is also self-dual, with hemi-dodecahedral facets. It was discovered by H. S. M. Coxeter shortly after the discovery of the 11-cell. Like the 11-cell, it is also universal, being the only polytope with hemi-dodecahedral facets and hemi-icosahedral vertex figures. On the other hand, there are many other polytopes with hemi-dodecahedral facets and Schläfli type {5,3,5}. The universal polytope with hemi-dodecahedral facets and icosahedral (not hemi-icosahedral) vertex figures is finite, but very large, with 10006920 facets and half as many vertices.

### Local topology

The amalgamation problem has, historically, been pursued according to local topology. That is, rather than restricting K and L to be particular polytopes, they are allowed to be any polytope with a given topology, that is, any polytope tessellating a given manifold. If K and L are spherical (that is, tessellations of a topological sphere), then P is called locally spherical and corresponds itself to a tessellation of some manifold. For example, if K and L are both squares (and so are topologically the same as circles), P will be a tessellation of the plane, torus or Klein bottle by squares. A tessellation of an n-dimensional manifold is actually a rank n + 1 polytope. This is in keeping with the common intuition that the Platonic solids are three dimensional, even though they can be regarded as tessellations of the two-dimensional surface of a ball.

In general, an abstract polytope is called locally X if its facets and vertex figures are, topologically, either spheres or X, but not both spheres. The 11-cell and 57-cell are examples of rank 4 (that is, four-dimensional) locally projective polytopes, since their facets and vertex figures are tessellations of real projective planes. There is a weakness in this terminology however. It does not allow an easy way to describe a polytope whose facets are tori and whose vertex figures are projective planes, for example. Worse still if different facets have different topologies, or no well-defined topology at all. However, much progress has been made on the complete classification of the locally toroidal regular polytopes (McMullen & Schulte, 2002)

## Exchange maps

Let Ψ be a flag of an abstract n-polytope, and let −1 < i < n. From the definition of an abstract polytope, it can be proven that there is a unique flag differing from Ψ by a rank i element, and the same otherwise. If we call this flag Ψ(i), then this defines a collection of maps on the polytopes flags, say φi. These maps are called exchange maps, since they swap pairs of flags : (Ψφi)φi = Ψ always. Some other properties of the exchange maps :

• φi2 is the identity map
• The φi generate a group. (The action of this group on the flags of the polytope is an example of what is called the flag action of the group on the polytope)
• If |i − j| > 1, φiφj = φjφi
• If α is an automorphism of the polytope, then αφi = φiα
• If the polytope is regular, the group generated by the φi is isomorphic to the automorphism group, otherwise, it is strictly larger.

The exchange maps and the flag action in particular can be used to prove that any abstract polytope is a quotient of some regular polytope.

## Incidence matrices

A polytope can also be represented by tabulating its incidences. The following incidence matrix is that of a triangle:

ø a b c ab bc ca abc
ø
a
b
c
ab
bc
ca
abc

The table shows a dot wherever a face is a subface of another, or vice versa (so the table is symmetric about the diagonal)- so in fact, the table has redundant information; it would suffice to show only a dot when the row face ≤ the column face.

Since both the body and the empty set are incident with all other elements, the first row and column as well as the last row and column are trivial and can conveniently be omitted.

Further information is gained by counting each occurrence of an incidence as 1 (and hence non-incidence as 0). This numerative usage enables a symmetry grouping, as in the Hasse Diagram of the square pyramid: If vertices B, C, D, and E are considered symmetrically equivalent within the abstract polytope, then edges f, g, h, and j will be grouped together, and also edges k, l, m, and n, And finally also the triangles 'P', 'Q', 'R', and 'S'. Thus the corresponding incidence matrix of this abstract polytope may be shown as:

A   B,C,D,E f,g,h,j k,l,m,n P,Q,R,S   T
A 1 * 4 0 4 0
B,C,D,E * 4 1 2 2 1
f,g,h,j 1 1 4 * 2 0
k,l,m,n 0 2 * 4 1 1
P,Q,R,S 1 2 2 1 4 *
T 0 4 0 4 * 1

In this accumulated incidence matrix representation the diagonal entries represent the total counts of either element type.

Elements of different type of the same rank clearly are never incident so the value will always be 0, however to help distinguish such relationships, an asterisk (*) is used instead of 0.

The sub-diagonal entries of each row represent the incidence counts of the relevant sub-elements, while the super-diagonal entries represent the respective element counts of the vertex-, edge- or whatever -figure.

Already this simple square pyramid shows that the symmetry-accumulated incidence matrices are no longer symmetrical. But there is still a simple entity-relation (beside the generalised Euler formulae for the diagonal, respectively the sub-diagonal entities of each row, respectively the super-diagonal elements of each row - those at least whenever no holes or stars etc. are considered), as for any such incidence matrix ${\displaystyle I=(I_{ij})}$ holds:

${\displaystyle I_{ii}\cdot I_{ij}=I_{ji}\cdot I_{jj}\ \ (i

## History

In the 1960s Branko Grünbaum issued a call to the geometric community to consider generalizations of the concept of regular polytopes that he called polystromata. He developed a theory of polystromata, showing examples of new objects including the 11-cell.

The 11-cell is a self-dual 4-polytope whose facets are not icosahedra, but are "hemi-icosahedra" — that is, they are the shape one gets if one considers opposite faces of the icosahedra to be actually the same face (Grünbaum, 1977). A few years after Grünbaum's discovery of the 11-cell, H.S.M. Coxeter discovered a similar polytope, the 57-cell (Coxeter 1982, 1984), and then independently rediscovered the 11-cell.

With the earlier work by Branko Grünbaum, H. S. M. Coxeter and Jacques Tits having laid the groundwork, the basic theory of the combinatorial structures now known as abstract polytopes was first described by Egon Schulte's in his 1980 PhD dissertation. In it he defined "regular incidence complexes" and "regular incidence polytopes". Subsequently, he and Peter McMullen developed the basics of the theory in a series of research articles that were later collected into a book. Numerous other researchers have since made their own contributions, and the early pioneers (including Grünbaum) had also accepted Schulte's definition as the "correct" one.

Since then, research in the theory of abstract polytopes has focused mostly on regular polytopes, that is, those whose automorphism groups act transitively on the set of flags of the polytope.


text:
# Generate SQL query by loop

I need to perform SQL query which will get products from database based on few dimensions which I will pass in URL.

import itertools

sql_where = ''
dimensions = ['a','b', 'c', 'd', 'e', 'f', 'f2', 'g']

for dimension in dimensions:
for onetwo, direction in zip( range(1, 3), itertools.cycle('><') ):
globals()[dimension+str(onetwo)] = str( request.GET.get( dimension+str(onetwo) ) )
sql_where += " AND ( {dimension} {direction}= '{get_dimension}' OR '{get_dimension}' = ('None' OR '') )".format(dimension=dimension, direction=direction, get_dimension=globals()[dimension+str(onetwo)])

sql = """SELECT * FROM t_wishbone_dimensions WHERE 1=1""" + sql_where
print sql

Example output for /search?a1=34&a2=37&c1=50&c2=75

SELECT * FROM t_wishbone_dimensions
WHERE 1=1
AND ( a >= '34' OR '34' = ('None' OR '') )
AND ( a <= '37' OR '37' = ('None' OR '') )
AND ( b >= 'None' OR 'None' = ('None' OR '') )
AND ( b <= 'None' OR 'None' = ('None' OR '') )
AND ( c >= '50' OR '50' = ('None' OR '') )
AND ( c <= '75' OR '75' = ('None' OR '') )
AND ( d >= 'None' OR 'None' = ('None' OR '') )
AND ( d <= 'None' OR 'None' = ('None' OR '') )
AND ( e >= 'None' OR 'None' = ('None' OR '') )
AND ( e <= 'None' OR 'None' = ('None' OR '') )
AND ( f >= 'None' OR 'None' = ('None' OR '') )
AND ( f <= 'None' OR 'None' = ('None' OR '') )
AND ( f2 >= 'None' OR 'None' = ('None' OR '') )
AND ( f2 <= 'None' OR 'None' = ('None' OR '') )
AND ( g >= 'None' OR 'None' = ('None' OR '') )
AND ( g <= 'None' OR 'None' = ('None' OR '') )

What do you think about my solution?

• '34' = ('None' OR '') makes no sense. What are you really trying to accomplish? Aug 29 '16 at 14:30
• @200_succes Because in the first stage I did not have loop but only one universal query pattern (with all dimensions) and I had to take into account cases when I will not give some dimension, then dimension value is "None". Aug 30 '16 at 5:20
• I think what he meant is, shouldn't this be something like OR a == 'None' OR a == ''? Aug 30 '16 at 8:56
• Also, you should be able to handle this with code, because you know the constraints and you know all dimensions. Just add None checks for all dimensions which are unconstrained... Aug 30 '16 at 8:59
• Finally I cut my AND condition to "AND ( {0} {1}= '{2}' )" and I eliminate the dimensions, which are not given, by the condition: val = request.GET.get(dimension+i, None) if val is not None: sql_where.append(AND_STR.format(dimension, DIRS[int(i)], val)) Aug 30 '16 at 9:06

## 2 Answers

Since I didn't want to setup a webserver for this, I added a bare class, which should behave in the same way as your request.GET:

class request:
GET = dict(a1=34, a2=37, c1=50, c2=75)

You should avoid setting keys in globals(), it clutters the namespace too much. Instead just use the default keyword of the get method of a dictionary, which will give you the specified value if the key is not present.

get_dimension = request.GET.get(dim, 'None')

You can make your string formatting a bit easier to understand if you split it up a bit. I made the string itself a constant (avoiding having to allocate it multiple times) and used positional arguments, instead of keywords (which, admittedly, hurts the readability slightly).

Instead of doing a string addition every loop, it is better to append to a list and do one join at the end, because string addition means creating an intermediate new string, since strings are immutable.

sql = "SELECT * FROM t_wishbone_dimensions WHERE 1=1" + "\n".join(sql_where)

I would also use itertools.product to replace your double loop, so something like:

directions = {'1': '>', '2': '<'}
dimensions = ['a', 'b', 'c', 'd', 'e', 'f', 'f2', 'g']
for dimension, i in itertools.product(dimensions, ('1', '2')):
direction = directions[i]
...

To improve readability you should separate the ANDs with a newline each (like you did in your example output).

Lastly, python has an official style guide, PEP8, which recommends having a blank after a comma in an argument list (in dimensions after 'a', one was missing), as well as not adding unnecessary whitespace (so usually no str( something ), but just str(something)).

Final code:

import itertools

class request:
# should handle the same same as your request.GET
GET = dict(a1=34, a2=37, c1=50, c2=75)

dimensions = ['a', 'b', 'c', 'd', 'e', 'f', 'f2', 'g']
DIRS = {'1': '>', '2': '<'}
AND_STR = "AND ( {0} {1}= '{2}' OR '{2}' = ('None' OR '') )"

sql_where = ['']
for dimension, i in itertools.product(dimensions, ('1', '2')):
val = request.GET.get(dimension+i, 'None')
sql_where.append(AND_STR.format(dimension, DIRS[i], val))
sql = "SELECT * FROM t_wishbone_dimensions WHERE 1=1" + "\n".join(sql_where)
print sql

Output:

SELECT * FROM t_wishbone_dimensions WHERE 1=1
AND ( a >= '34' OR '34' = ('None' OR '') )
AND ( a <= '37' OR '37' = ('None' OR '') )
AND ( b >= 'None' OR 'None' = ('None' OR '') )
AND ( b <= 'None' OR 'None' = ('None' OR '') )
AND ( c >= '50' OR '50' = ('None' OR '') )
AND ( c <= '75' OR '75' = ('None' OR '') )
AND ( d >= 'None' OR 'None' = ('None' OR '') )
AND ( d <= 'None' OR 'None' = ('None' OR '') )
AND ( e >= 'None' OR 'None' = ('None' OR '') )
AND ( e <= 'None' OR 'None' = ('None' OR '') )
AND ( f >= 'None' OR 'None' = ('None' OR '') )
AND ( f <= 'None' OR 'None' = ('None' OR '') )
AND ( f2 >= 'None' OR 'None' = ('None' OR '') )
AND ( f2 <= 'None' OR 'None' = ('None' OR '') )
AND ( g >= 'None' OR 'None' = ('None' OR '') )
AND ( g <= 'None' OR 'None' = ('None' OR '') )

• Thank you very much for your involvement! I added unnecessary whitespaces between bracklets because it causes better readability for me. Especially in long lines of code. Even if it is not properly way. Why did you use square brackets in sql_where var? itertools.product() is better solution than combine zip() with itertools.cycle() :) Aug 30 '16 at 5:58
• I made sql_where a list, because string addition is costly, and list appending followed by a single join not so much. I know why you put the space there, and I sometimes agree. In the end, it is a style guide. But adhering to it as much as possible ensures that other people can easily read your code as well as you can. Aug 30 '16 at 8:54

The query that ends up being generated is VERY difficult to read/understand and will likely cause you problems in debugging down the line.

I guess I am not understanding why you have a bunch of WHERE clause fragments for parameters/dimensions that are not even pertinent to the filtering operation.

Taking your example URL of:

/search?a1=34&a2=37&c1=50&c2=75

I would think you should strive for a resulting WHERE clause that looks like:

WHERE a BETWEEN '34' AND '37'
AND c BETWEEN '50' AND '75'

Note that you would probably need to work with the parameter values as integers rather than strings as shown in this example if you did not want a lexicographical comparison.

Note that this could also greatly improve the performance of the query itself as you will no longer be requiring the query execution to have to look at all the indexes for all fields even in the cases where the field filters are totally meaningless.

The bottom line here is to write a good query first, then figure out how to generate it dynamically in your code.

To get to this point, I think you need to abandon the approach of iterating through each known dimension/field, concatenating meaningless where clauses in the process and actually work with the parameters passed via GET. Those are what you should be iterating on.

You might also consider using a URL format like

/search?a[]=34&a[]=37&c[]=50&c[]=75

Where you can use the bracket notation to indicate an array of values. This allows for you to handle a list of values of arbitrary length rather than have a series of a*, b*, c*, etc. values that you need to account for throughout your code. Of course, you might need to use getlist() or similar to get the list of values rather than just the last item from the list.

In the query, you might consider not using SELECT *. This is a bit of lazy code writing, IMO, and it makes it harder for someone reading the code, who may not have visibility into the database schema itself, to understand what the expected field values are. This can also cause more data being returned than is necessary as in most complex applications, the database tables may have a number of timestamp/audit type of fields that are not really meant to be consumed by the application, so why send this field data to the application if it is not needed?

Finally, I would point out that some of your lines of code are too long, making the code hard to read.

This line for example is particularly bad:

sql_where += " AND ( {dimension} {direction}= '{get_dimension}' OR '{get_dimension}' = ('None' OR '') )".format(dimension=dimension, direction=direction, get_dimension=globals()[dimension+str(onetwo)])

Break this up across multiple lines so that it is easier to read and understand.

Update - data validation

You also are not currently validating your input at all. I think if you implement proper input validation, this would go hand in hand with answering your question about how to build SQL query filter based only on those parameters passed.

At the very start of your code, I would iterate through each of the parameters passed in the request and validate that:

• the parameters match your expected available dimensions; and
• that the values of the parameters match whatever data type and value rules you might consider (i.e. integer values, non-zero length strings, etc.)

In doing this, you now know exactly which dimensions you should be applying to your filter - only those that pass this validation.

How you decide to handle cases of unexpected parameters or validation failure is really up to you, but clearly in those cases, you would not want to apply filtering on those dimensions.

• WHERE a IN ('34', '37') AND c IN ('50', '75') but a is not 34 or 37 but 34 <= a <= 37. When will I work only with parameters passed via GET, what with security then? Should I compare passed parameters with allowed list? I used SELECT * because that table include only dimensions columns, so I need get everything. But I know what you mean. Aug 30 '16 at 17:36
• @user3041764 O I didnt get the meaning of the filtering fields a1, a2 as being bounds - more meaningful parameter names and field names would REALY help in this case. It just goes to show how unintelligible the current query is. Yes. You should validate all passed parameters in this and every other application you write. This is user input and should never be the basis for forming a query without such validation as you currently have SQL injection vulnerability. You could potentially keep your iteration the same, but perhaps just not modify the where clause if parameter not present. Aug 30 '16 at 18:02
• @user3041764 I modified my answer to show the use of a "BETWEEN" clause instead of IN based on your comment. This actually introduces the problem of needing to work with these values perhaps as integers instead of strings, as you are likely not wanting to have cases where '11' evaluates as being between '1' and '2' as would be the case if you were searching lexicographically. Aug 30 '16 at 18:06
• I changet GET method to POST and I do $('form').serialize() and it pass all inputs to request, even if they are empty. I tried $("form :input[value!='']").serialize() but with no result. Have you idea how can I filter and build query based only on passed and not empty paremeters? Sep 1 '16 at 11:51
• @user3041764 I guess I didn't understand the question as there was no front end code as part of this review at all. If you have a form that is POSTing to this python script - you have two simply choices. Either filter about empty form fields in javascript before posting or in python simply ignore fields with empty values as part of the validation process. Sep 1 '16 at 17:12

format: plain


text:
Home Misc Divide a number by 3 without using *, /, +, -, % operators

# Divide a number by 3 without using *, /, +, -, % operators

0 comment

Question:

How can you divide a number by 3 without using *, /, +, – % operator?

Input: 48
Output: 16

The method below implements the method using bit-wise operators.

//a function to add 2 numbers without using +
{
int a, b;
do
{
a = x & y;
b = x ^ y;
x = a << 1;
y = b;
} while (a);

return b;
}

int divideby3(int num)
{
int sum = 0;

while (num > 3)
{
sum = add(num >> 2, sum);
num = add(num >> 2, num & 3);
}

if (num == 3)

return sum;
}

//the main function
int main(void)
{
printf("Enter a number:- ");
int num;
scanf("%d",&num);

printf("The number divided by 3 is:- %d",divideby3(num));

return 0;
}

For example if your number is 10 then convert to binary
10 =>00001010
if 10 > 3 then shift the binary number 2 bits
Now num will be 00000010 ie, 2
Now sum will be 2
num = (shift the number by 2 bits)+(number BITWISE AND 3)
num = 2+2

Now the number will be 4 then, 4>3 => true so loop will be repeated
4=>00000100 then shift the binary number 2 bits
Now sum=2+1 ie, sum=3   (this value is returned)
num=(shift the number(00000100) by 2 bits)+(number BITWISE AND 3)
num=1+0
ie remainder=1

#### You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More


text:
Examples of CY fibrations over $\mathbb P^1$

We work over $$\mathbb C$$ and let us call a smooth projective vartiety $$M$$ as Calabi-Yau (CY) manifold if it has trivial canonical class and $$h^i(M, \mathcal O_M ) = 0$$ for $$0 < i < \dim(M)$$. In this definition, a CY 1-fold is an elliptic curve, a CY 2-fold is a projective $$K3$$ surface and etc.

For each $$n$$, I looking for a smooth projective variety $$X$$ of dimension $$n$$ with a fibration $$\pi: X \rightarrow \mathbb P^1$$ such that

1. a generic fiber $$F$$ of $$\pi$$ is a CY $$(n-1)$$-fold
2. $$K_X$$ is linearly equivalent to $$-2F$$ and
3. $$X$$ is not a product of $$\mathbb P^1$$ and a CY $$(n-1)$$-fold.

For $$n=2$$, it is known that such $$X$$ (an ellitic surface) does not exist. I put a question regarding the case of $$n=3$$ here but didn't get an answer. I also put a stronger question here, requiring a different condition that every fiber is smooth and got answers saying that there are no such fibrations with the smooth condition.

For some $$n$$, does such a fibration exist?

• "For $n=2$, it is known that such an $X$ . . . does not exist." Elliptic K3 surfaces do exist. More generally, for a sufficiently general hypersurface in $\mathbb{P}^n\times \mathbb{P}^1$ of bidegree $(n+1,2)$, the hypersurface together with its projection to $\mathbb{P}^1$ is an example satisfying your conditions. May 21 '21 at 13:23
• @JasonStarr, your example does not seem to satisfy the second condition. May 21 '21 at 13:36
• Sorry, I thought that you wanted the relative canonical divisor to be linearly equivalent to $2F$, not the anticanonical divisor. You are correct that my examples are Calabi-Yau manifolds, thus the anticanonical divisor is trivial. i May 21 '21 at 14:34

Edit. There is a mistake in the answer below. It is possible that the fiber of the rational quotient has dimension $$\geq 2$$. I will try to revise the answer soon.
Original answer (including mistake). If the anticanonical divisor class is numerically equivalent to $$2F$$, then by Mori's Bend-and-Break result, every point of your variety is contained in a rational curve. If the general fiber is a Calabi-Yau variety, then it is not uniruled. Thus, every rational curve containing a general point is not contained in the fiber. For transversal rational curves, deformation theory gives a lower bound on the dimension of the space of deformations containing the fixed (yet general) point: the lower bound is the anticanonical degree minus $$2$$. By Bend-and-Break again, that means that the minimal anticanonical degree of a transversal rational curve containing a general point is precisely $$2$$, i.e., the curve is a section of the fibration.
Moreover, the normal bundle is globally generated for every irreducible rational curve containing a general point, so the normal bundle is a trivial bundle. The following sentence is wrong. That means that the "rational quotient" of $$X$$ by these transversal rational curves is a $$\mathbb{P}^1$$-bundle over the quotient, and the fibers of the original fibration are mapping finitely to this quotient (away from codimension $$2$$). Why this is a mistake: in fact, there are rational quotients by such curves where the fiber dimension of the rational quotient map is strictly greater than $$1$$, e.g., cubic threefolds where the curve is a general line. Since the fibers (of the projection to $$\mathbb{P}^1$$) are themselves Calabi-Yau, this should force the finite maps to be étale. Since Calabi-Yau varieties are simply connected, this should force the finite maps to be isomorphisms. So the rational quotient provides the projection to the fiber factor of the product of $$\mathbb{P}^1$$ and the fiber.


text:
# Parallel Law for Extremal Length

## Theorem

Let $X$ be a Riemann surface.

Let $\Gamma_1, \Gamma_2$ be families of rectifiable curves (or, more generally, families of disjoint unions of rectifiable curves) on $X$.

Let $\Gamma_1$ and $\Gamma_2$ be disjoint, in the sense that:

there exist disjoint Borel subsets $A_1, A_2 \subseteq X$ such that:
for any $\gamma_1 \in \Gamma_1$ and $\gamma_2 \in \Gamma_2$, we have $\gamma_1 \subseteq A_1$ and $\gamma_2 \subseteq A_2$.

Let $\Gamma$ be a third curve family, with the property that every element $\Gamma_1$ and every element of $\Gamma_2$ contains some element of $\Gamma$.

Then the extremal length of $\Gamma$ satisfies:

$\dfrac 1 {\lambda \left({\Gamma}\right)} \ge \dfrac 1 {\lambda \left({\Gamma_1}\right)} + \dfrac 1 {\lambda \left({\Gamma_2}\right)}$

## Proof

The assumption means that every element of $\Gamma_1 \cup \Gamma_2$ contains some element of $\Gamma$.

Hence:

 $\ds \frac 1 {\lambda \left({\Gamma}\right)}$ $\ge$ $\ds \frac 1 {\lambda \left({\Gamma_1 \cup \Gamma_2}\right)}$ Comparison Principle for Extremal Length $\ds$ $=$ $\ds \frac 1 {\lambda \left({\Gamma_1}\right)} + \frac 1 {\lambda \left({\Gamma_2}\right)}$ Extremal Length of Union

$\blacksquare$


text:
# Command forms

## General command form¶

In a shell (bash here), there are a multitude of commands accessible by the command interpreter. However, these commands (almost) all follow the same syntax:

command [option] [argument]

• command is the name of the command to be executed

• The [...] in [option] and [argument] means that the options and arguments are optional. So the command can be called alone and will then be executed with its default options.

• The various components of the commands are separated by spaces.

• [option] corresponds to the options. They are usually of the form -o (with a dash) or --option (long version with two dashes). Options can sometimes be followed by arguments specific to the options (for example -o toto or --option=toto). If several options are defined, they can often be abbreviated (eg -a -b becomes -ab).

• [argument] matches the command's own arguments.

Example:

ls
ls directory
ls -d directory
ls -l -a
ls -la
ls -la directory


text:
Ideal Gas Law - Differential Approximation due to variable increase in %.

Homework Statement

This is a problem form my calculus book, which states:

According to the ideal gas law, the pressure, temperature, and volume of a confined gas are related by P=kT/V, where K is a constant. Use differentials to approximate the percentage change in pressure if the temperature of a gas is increased 3% and the volume is increased 5%.

The Attempt at a Solution

Here, I include my original attempt at the solution and a solution that I found online. In my original solution, I found the answer to be 2%, but the solution says 4%. I'm not sure why... but I think it's related to something I don't understand in the actual solution, where it seems to me, they divide by 1/2 for no apparent logical reason.

Could someone please explain to me where my logic is flawed?

Here is a solution I found online to the same problem, perhaps it's more clear.

Attachments

• calc_diff.jpg
19.5 KB · Views: 2,231
• Calc_Diff_hand.jpg
92.4 KB · Views: 1,118
Last edited:


text:
# pypy / pypy / doc / project-ideas.rst

 Maciej Fijalkows… 9ad0aa5 2011-06-03 Maciej Fijalkows… 382d205 2011-06-04 Maciej Fijalkows… 23e4b5d 2011-06-04 Maciej Fijalkows… acfe609 2011-11-22 Antonio Cuni 82e0779 2012-11-28 Maciej Fijalkows… 9ad0aa5 2011-06-03 Armin Rigo 9e1ad87 2011-11-21 Maciej Fijalkows… 9ad0aa5 2011-06-03 Armin Rigo 9e1ad87 2011-11-21 Maciej Fijalkows… 9ad0aa5 2011-06-03 Antonio Cuni 6ef744e 2011-06-06 Maciej Fijalkows… 9ad0aa5 2011-06-03 Maciej Fijalkows… ae33c95 2011-06-04 Antonio Cuni 6ef744e 2011-06-06 Alex Gaynor 1f10820 2011-06-06 Antonio Cuni 6ef744e 2011-06-06 Maciej Fijalkows… 9ad0aa5 2011-06-03 Carl Friedrich B… 1bd0227 2011-09-29 Amaury Forgeot d… 7dcc322 2011-06-04 Maciej Fijalkows… 9ad0aa5 2011-06-03 Maciej Fijalkows… 23e4b5d 2011-06-04 Maciej Fijalkows… 9ad0aa5 2011-06-03 Armin Rigo 18611e0 2012-09-21 Maciej Fijalkows… 9ad0aa5 2011-06-03 Armin Rigo 18611e0 2012-09-21 Armin Rigo 6f82f37 2012-09-28 Maciej Fijalkows… 23e4b5d 2011-06-04 Armin Rigo 18611e0 2012-09-21 Armin Rigo 6f82f37 2012-09-28 Armin Rigo 18611e0 2012-09-21 Armin Rigo 1f78bbb 2011-06-04 Maciej Fijalkows… 7fac887 2011-06-07 Maciej Fijalkows… 23e4b5d 2011-06-04 Maciej Fijalkows… 9ad0aa5 2011-06-03 Armin Rigo 882f8fd 2011-06-13 Armin Rigo 38129ef 2011-06-21 wlav ec9d1ae 2012-04-02 Armin Rigo 38129ef 2011-06-21 Maciej Fijalkows… 72ec6b7 2011-06-04 Alex Gaynor b8398a4 2011-06-06  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 Potential project list ====================== This is a list of projects that are interesting for potential contributors who are seriously interested in the PyPy project. They mostly share common patterns - they're mid-to-large in size, they're usually well defined as a standalone projects and they're not being actively worked on. For small projects that you might want to work on, it's much better to either look at the issue tracker_, pop up on #pypy on irc.freenode.net or write to the mailing list_. This is simply for the reason that small possible projects tend to change very rapidly. This list is mostly for having on overview on potential projects. This list is by definition not exhaustive and we're pleased if people come up with their own improvement ideas. In any case, if you feel like working on some of those projects, or anything else in PyPy, pop up on IRC or write to us on the mailing list_. Make bytearray type fast ------------------------ PyPy's bytearray type is very inefficient. It would be an interesting task to look into possible optimizations on this. Implement copy-on-write list slicing ------------------------------------ The idea is to have a special implementation of list objects which is used when doing myslice = mylist[a:b]: the new list is not constructed immediately, but only when (and if) myslice or mylist are mutated. Numpy improvements ------------------ The numpy is rapidly progressing in pypy, so feel free to come to IRC and ask for proposed topic. A not necesarilly up-to-date list of topics_ is also available. .. _list of topics: https://bitbucket.org/pypy/extradoc/src/extradoc/planning/micronumpy.txt Improving the jitviewer ------------------------ Analyzing performance of applications is always tricky. We have various tools, for example a jitviewer_ that help us analyze performance. The jitviewer shows the code generated by the PyPy JIT in a hierarchical way, as shown by the screenshot below: - at the bottom level, it shows the Python source code of the compiled loops - for each source code line, it shows the corresponding Python bytecode - for each opcode, it shows the corresponding jit operations, which are the ones actually sent to the backend for compiling (such as i15 = i10 < 2000 in the example) .. image:: image/jitviewer.png The jitviewer is a web application based on flask and jinja2 (and jQuery on the client): if you have great web developing skills and want to help PyPy, this is an ideal task to get started, because it does not require any deep knowledge of the internals. Optimized Unicode Representation -------------------------------- CPython 3.3 will use an optimized unicode representation_ which switches between different ways to represent a unicode string, depending on whether the string fits into ASCII, has only two-byte characters or needs four-byte characters. The actual details would be rather differen in PyPy, but we would like to have the same optimization implemented. .. _optimized unicode representation: http://www.python.org/dev/peps/pep-0393/ Translation Toolchain --------------------- * Incremental or distributed translation. * Allow separate compilation of extension modules. Various GCs ----------- PyPy has pluggable garbage collection policy. This means that various garbage collectors can be written for specialized purposes, or even various experiments can be done for the general purpose. Examples * An incremental garbage collector that has specified maximal pause times, crucial for games * A garbage collector that compact memory better for mobile devices * A concurrent garbage collector (a lot of work) STM (Software Transactional Memory) ----------------------------------- This is work in progress. Besides the main development path, whose goal is to make a (relatively fast) version of pypy which includes STM, there are independent topics that can already be experimented with on the existing, JIT-less pypy-stm version: * What kind of conflicts do we get in real use cases? And, sometimes, which data structures would be more appropriate? For example, a dict implemented as a hash table will suffer "stm collisions" in all threads whenever one thread writes anything to it; but there could be other implementations. Maybe alternate strategies can be implemented at the level of the Python interpreter (see list/dict strategies, pypy/objspace/std/{list,dict}object.py). * More generally, there is the idea that we would need some kind of "debugger"-like tool to "debug" things that are not bugs, but stm conflicts. How would this tool look like to the end Python programmers? Like a profiler? Or like a debugger with breakpoints on aborted transactions? It would probably be all app-level, with a few hooks e.g. for transaction conflicts. * Find good ways to have libraries using internally threads and atomics, but not exposing threads to the user. Right now there is a rough draft in lib_pypy/transaction.py, but much better is possible. For example we could probably have an iterator-like concept that allows each loop iteration to run in parallel. Introduce new benchmarks ------------------------ We're usually happy to introduce new benchmarks. Please consult us before, but in general something that's real-world python code and is not already represented is welcome. We need at least a standalone script that can run without parameters. Example ideas (benchmarks need to be got from them!): * hg Experiment (again) with LLVM backend for RPython compilation ------------------------------------------------------------ We already tried working with LLVM and at the time, LLVM was not mature enough for our needs. It's possible that this has changed, reviving the LLVM backend (or writing new from scratch) for static compilation would be a good project. (On the other hand, just generating C code and using clang might be enough. The issue with that is the so-called "asmgcc GC root finder", which has tons of issues of this own. In my opinion (arigo), it would be definitely a better project to try to optimize the alternative, the "shadowstack" GC root finder, which is nicely portable. So far it gives a pypy that is around 7% slower.) Embedding PyPy ---------------------------------------- Being able to embed PyPy, say with its own limited C API, would be useful. But here is the most interesting variant, straight from EuroPython live discussion :-) We can have a generic "libpypy.so" that can be used as a placeholder dynamic library, and when it gets loaded, it runs a .py module that installs (via ctypes) the interface it wants exported. This would give us a one-size-fits-all generic .so file to be imported by any application that wants to load .so files :-) Optimising cpyext (CPython C-API compatibility layer) ----------------------------------------------------- A lot of work has gone into PyPy's implementation of CPython's C-API over the last years to let it reach a practical level of compatibility, so that C extensions for CPython work on PyPy without major rewrites. However, there are still many edges and corner cases where it misbehaves, and it has not received any substantial optimisation so far. The objective of this project is to fix bugs in cpyext and to optimise several performance critical parts of it, such as the reference counting support and other heavily used C-API functions. The net result would be to have CPython extensions run much faster on PyPy than they currently do, or to make them work at all if they currently don't. A part of this work would be to get cpyext into a shape where it supports running Cython generated extensions. .. _issue tracker: http://bugs.pypy.org .. _mailing list: http://mail.python.org/mailman/listinfo/pypy-dev .. _jitviewer: http://bitbucket.org/pypy/jitviewer
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.


text:
## LaTeX forum ⇒ Math & Science ⇒ Can't set vertical whitespace in the preamble

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

### Can't set vertical whitespace in the preamble

Hi all,

I was redefining vertical whitespace between formulas and text, which is controlled by four lengths, according to Voss' Math mode: \abovedisplayskip, \abovedisplayshortskip, \belowdisplayskip and \belowdisplayhortskip. Surprisingly for me, setting up those lengths in the preamble did nothing, I can only redefine them inside the document. Please test the following example (don't pay much attention to the typeset text ), in which I try to introduce a huge whitespace just before the formula:

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\setlength\parindent{0pt}

% This won't work
\setlength\abovedisplayskip{40pt}

\begin{document}

This is the first line, which just fills space with text before the formula:
$f(x) = \int_0^{\infty} \frac{\sin x}{x}\ dx$
after the formula, this line works as a reference to see the vertical spacing.
\vspace{2\baselineskip}

% This time it will work
\setlength\abovedisplayskip{40pt}

This is the first line, which just fills space with text before the formula:
$f(x) = \int_0^{\infty} \frac{\sin x}{x}\ dx$
after the formula, this line works as a reference to see the vertical spacing.

\end{document}

Could somebody explain me this behavior? Why won't it let me set these lengths in the preamble, while I can set others?

localghost
Site Moderator
Posts: 9203
Joined: Fri Feb 02, 2007 12:06 pm
The values of these lengths are determined by the font size. Hence it is not enough to set them in the preamble.

Best regards
Thorsten¹
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm
Thanks localghost, I understand it now. So, no matter what I put in the preamble, once the document starts these lengths will be reset to a value depending on font size, right? OK, now I know what to do if it happens again with other length commands, thanks!

localghost
Site Moderator
Posts: 9203
Joined: Fri Feb 02, 2007 12:06 pm
Keta wrote:[...] OK, now I know what to do if it happens again with other length commands, thanks! [...]

You must not generalize this for all lengths. The most length registers can be set very well in the preamble. But there may be others apart from these here which can't.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am
Keta,

If you need to set \abovedisplayskip in the preamble, write there a line like
\AtBeginDocument{\setlength\abovedisplayskip{40pt}}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm
Thanks Juanjo, very helpful!

Stefan Kottwitz
Posts: 9705
Joined: Mon Mar 10, 2008 9:44 pm
Hi Keta!

Commands like \normalsize, \small and \footnotesize could change the length of \abovedisplayskip, \belowdisplayskip etc. You could read it for example in bk12.clo in the directory where the LaTeX base classes are located.
Juanjos approach could work, but if some macro calls for instance \normalsize the value of \abovedisplayskip etc. would be changed back.

You could redefine \normalsize etc. according to the class. But here's a short way, using this you don't need to rewrite the original definition of \normalsize:
\makeatletter
\makeatother

or alternatively
\expandafter\def\expandafter\normalsize\expandafter{%
\normalsize\setlength\abovedisplayskip{40pt}}

See perhaps Using \expandafter for macro redefinitions.

This will work in the preamble, tested with your example.

Stefan


text:
# What are the critical points of f(x) = 1/sqrt(x+x^2-3)?

Dec 7, 2015

The critical points for $f \left(x\right)$ are

$\left\{- \frac{1}{2} , \frac{- 1 + \sqrt{13}}{2} , \frac{- 1 - \sqrt{13}}{2}\right\}$

#### Explanation:

The critical points of a function $f \left(x\right)$ are the points $c$ at which $f ' \left(c\right) = 0$ or $f ' \left(c\right)$ is undefined.
Thus first we find the derivative of the function, and then set it equal to zero.

To find the derivative we apply the quotient rule, the chain rule, and the power rule:

$f ' \left(x\right) = \frac{d}{\mathrm{dx}} \frac{1}{\sqrt{x + {x}^{2} - 3}}$

$= - \frac{\frac{1}{2} {\left(x + {x}^{2} - 3\right)}^{- \frac{1}{2}} \left(2 x + 1\right)}{x + {x}^{2} - 3}$

$= - \frac{2 x + 1}{2 {\left(x + {x}^{2} - 3\right)}^{\frac{3}{2}}}$

Now, to find the critical points, we want to find all points where $f '$ is $0$ or undefined.

Because $f ' \left(x\right) = 0 \iff 2 x + 1 = 0$
we can solve for $x$ to find a critical point at $- \frac{1}{2}$.

As $f ' \left(x\right)$ is undefined if and only if
$2 {\left(x + {x}^{2} - 3\right)}^{\frac{3}{2}} = 0 \iff {x}^{2} + x - 3 = 0$
we can use the quadratic formula to find critical points at
$\frac{- 1 \pm \sqrt{13}}{2}$

Thus the critical points for $f \left(x\right)$ are

$\left\{- \frac{1}{2} , \frac{- 1 + \sqrt{13}}{2} , \frac{- 1 - \sqrt{13}}{2}\right\}$


text:
Math Calendar

View Year

<>December 2013
November 2013
SMTWRFS
272829303112
3456789
10111213141516
17181920212223
24252627282930
December 2013
SMTWRFS
1234567
891011121314
15161718192021
22232425262728
2930311234
January 2014
SMTWRFS
2930311234
567891011
12131415161718
19202122232425
2627282930311

Log in to request a room reservation that will appear here for special events. Click on a day to view the room schedule for available times.

A live feed of seminars and special events in the upcoming week.

December 2nd, 2013 (12:20pm - 01:30pm)
Seminar: CCMA Luncheon Seminar
Title: Direct methods of the calculus of variations
Speaker: Wilfrid Gangbo, Georgia Institute of Technology
Location: MB114
Abstract: http://people.math.gatech.edu/~gangbo/

A theory, now called direct methods of the calculus of variations, was developed by Charles Morrey in the middle of the last century where he introduced various fundamental concepts of convexity. We will briefly comment on the concepts of lower semicontinuity and quasiconvexity and their importance in the calculus of variations. We will talk about the class of polyconvex functions, central in elasticity theory, and appearing in the study of extremal mappings of finite distortion.

December 2nd, 2013 (02:30pm - 03:30pm)
Seminar: Computational and Applied Mathematics Colloquium
Title: Polyconvex integrands in the calculus of variations
Speaker: Wilfrid Gangbo, Georgia Institute of Technology
Location: MB106
Abstract: http://people.math.gatech.edu/~gangbo/

In nonlinear elasticity theory, ones deals with functionals of the form u \to I(u) = \int (W(\nabla u) + u . F), where W is a function de ned on the set of dxd matrices, W(\xi) fails to be a convex function of  but is rather a convex function of the minors of \xi. Motivated by the study of Ogden material we consider functions satisfying lim det_{\xi \to 0+} W(\xi) = \infty$. For these functionals, identifying the Euler-Lagrange equations satis ed by the minimizers of I(.) remains an open outstanding problem in the calculus of variations. Furthermore, the current state of the art in the calculus of variations dramatically fails to predict the uniqueness of the minimizers of I(.) in many interesting cases. In this talk, we introduce a series of problems which we hope will contribute to a better understanding the above issues. This talk is based on a joint work with R. Awi. December 3rd, 2013 (10:00am - 10:50am) Seminar: Hyperbolic and Mixed Type PDEs Seminar Title: Linear Stability of Contact Discontinuities in Three-Dimensional Compressible Isentropic Steady Flows Speaker: Fang Yu, Penn State Location: MB216 In this talk, we will discuss the linear stability of contact discontinuities in three-dimensional compressible isentropic steady Euler equations for supersonic flows. By developing Kreiss, Coulombel and Secchi's arguments for a boundary value problem of hyperbolic equations involving poles in coefficients derived from the linearized problem at a supersonic planar contact discontinuity, we obtain a necessary and sufficient condition for the linear weak stability of contact discontinuities. Moreover, the a priori energy estimates of solutions to this linearized problem are also obtained in the weakly stable region by constructing appropriate symmetrizers microlocally. December 3rd, 2013 (02:30pm - 03:45pm) Seminar: Logic Seminar Title: Submeasures, supermeasures, and effective capacitability. Speaker: Stephen G. Simpson, Pennsylvania State University Location: MB315 I discuss submeasures and supermeasures on the Cantor space. I prove a lemma to the effect that if a supermeasure is bounded above by a submeasure, then there is a measure in between them. Using this lemma I prove that for any computable convex function f, strong f-randomness is equivalent to effective f-capacitability. This theorem is a generalization of an earlier result due to Reimann and Kjos-Hanssen. Using this theorem, I prove a product theorem for strong f-randomness. These new results are in the forthcoming paper "Cone avoidance and randomness preservation" by S. Simpson and F. Stephan. December 3rd, 2013 (02:30pm - 03:30pm) Seminar: GAP Seminar Title: Dirac operators and quantization Speaker: Jean-Philippe Michel, Université de Liège Location: MB106 Both Dirac operators and quantization maps (inverse of a symbol map) are of fundamental importance in mathematics. After reviewing both concepts, we develop a symbol calculus for spinor differential operators and present two applications: classification of symmetries of the standard (pseudo-Riemannian) Dirac operator and characterization of Courant algebroids through Dirac generating operators. The key step in our work is to associate a graded Poisson algebra to the algebra of spinor differential operators, thanks to a well-chosen filtration on the latter. December 4th, 2013 (10:00am - 12:00pm) Seminar: Ph.D. Oral Comprehensive Examination Title: "On Stochasticity of Graphs" Speaker: Jake Pardo, Adviser: Jan Reimann, Penn State Location: 123 Pond Laboratory Abstract: http:// Stochasticity has proven to be of paramount significance in mathematics; as such it only makes sense to rigorously expand the notion of stochasticity to graphs and graph-like objects. I will explain some usual ideas about stochasticity as well as some graph-ish objects that are potentially important in this project, and I will discuss a bit of what I have been working on lately. December 4th, 2013 (12:00pm - 01:30pm) Seminar: Geometry Luncheon Seminar Title: On Alexandrov spaces with maximal number of extremal points Speaker: Nina Lebedeva, PSU Shapiro Visitor Location: MB114 It is known that every n-dimensional Alexandrov space with nonnegative curvature has at most 2^n extremal points. We describe all Alexandrov spaces with exactly 2^n extremal points. December 5th, 2013 (10:00am - 10:50am) Seminar: Hyperbolic and Mixed Type PDEs Seminar Title: Linear Stability of Contact Discontinuities in Three-Dimensional Compressible Isentropic Steady Flows (Continued) Speaker: Fang Yu, Penn State Location: MB216 In this talk, we will discuss the linear stability of contact discontinuities in three-dimensional compressible isentropic steady Euler equations for supersonic flows. By developing Kreiss, Coulombel and Secchi's arguments for a boundary value problem of hyperbolic equations involving poles in coefficients derived from the linearized problem at a supersonic planar contact discontinuity, we obtain a necessary and sufficient condition for the linear weak stability of contact discontinuities. Moreover, the a priori energy estimates of solutions to this linearized problem are also obtained in the weakly stable region by constructing appropriate symmetrizers microlocally. December 5th, 2013 (11:00am - 01:00pm) Seminar: Mathematical Biology and Physiology Seminar Title: Dynamics of Neural Networks and Birdsong Syntax Speaker: Dezhe Jin, Department of Physics, Penn State University Location: MB216 Songbirds learn to sing like humans learn to speak. The songs of many species consist of sequences of discrete syllables. The sequences follow syntactical rules that have some rudimentary similarities to grammars in human language. Experimental and computational works have converged to unveil how the collective dynamics of connected neurons in the songbird brain controls the syntax. Neurons form unidirectional chain networks that drive the syllables. The chains are connected into branched networks. Neural activity flows along the branched pathway to produce syllable sequences. At a branching point, one of the connected chains is selected to carry on the activity, producing a probabilistic syllable transition. These results may shed light on how human speech is encoded in the brain. December 5th, 2013 (11:15am - 12:05pm) Seminar: Algebra and Number Theory Seminar Title: Unifying known lower bounds via geometric complexity theory Speaker: Josh Grochow, University of Toronto Location: MB106 Geometric Complexity Theory (GCT) is a program to resolve major open questions in complexity theory such as P vs NP, using algebraic geometry and representation theory. Although GCT was developed as a long-term program aimed primarily at P vs NP and permanent versus determinant, in this talk we show that essentially all known arithmetic circuit lower bounds and implications between lower bounds naturally fit into the representation-theoretic framework suggested by GCT. That is, the original proofs, with what is often just a little extra work, already provide representation-theoretic obstructions in the sense of GCT for their respective lower bounds. This enables us to expose a new viewpoint on GCT, whereby it is a natural unification of known results and broad generalization of known techniques in complexity. It also shows that the framework of GCT is at least as powerful as previous methods, and gives many new proofs-of-concept that GCT can indeed provide significant asymptotic complexity lower bounds. This new viewpoint also opens up the possibility of fruitful two-way interactions between previous results and the geometric and representation-theoretic methods of GCT; we provide several concrete suggestions of such interactions. This talk will assume essentially no background in complexity theory. December 5th, 2013 (02:30pm - 03:30pm) Seminar: Noncommutative Geometry Seminar Title: Detecting the K-theory of surface groups using quasi-representations Speaker: José Carrión, Penn State Location: MB106 We discuss how almost-multiplicative maps ("quasi-representations") of a group may be used to study associated K-theory groups. We focus on fundamental groups of orientable surfaces, where explicit computations can be carried out. This is based on joint work with Marius Dadarlat. December 5th, 2013 (05:00pm - 06:30pm) Seminar: SIAM Student Chapter Seminar Title: TBA Speaker: TBA Location: MB106 Abstract: http:// TBA December 6th, 2013 (04:40pm - 05:30pm) Seminar: Teaching Mathematics Discussion Group Seminar Title: Syllabus Writing Speaker: Attendees, Penn State University Location: MB106 What are your Dos and Don'ts for syllabus writing? This week we discuss we have learned about syllabus writing in past experiences. For more information about this discussion group, please visit http://bit.ly/19ySDan December 9th, 2013 (12:20pm - 01:30pm) Seminar: CCMA Luncheon Seminar Title: Viscous instability of the stable Poiseuille flow Speaker: Toan Nguyen, Penn State Location: MB114 Abstract: http://toannguyen.org I'll present a new, operator-based approach to establish spectral instability of generic plane shear profiles (hence, including those which are stable under corresponding Euler flows) in the 2D incompressible Navier-Stokes flows with small viscosity. Such a viscous destabilization phenomenon has been well-documented in the physical literature, going back to works of Heisenberg, C.C. Lin, Tollmien, and other prominent physicists. December 9th, 2013 (02:30pm - 03:30pm) Seminar: Computational and Applied Mathematics Colloquium Title: Mechanics of Protein Adhesion Speaker: Melik C. Demirel, Penn State, Engineering Department Location: MB106 Abstract: http://www.personal.psu.edu/mcd18/ The underlying motivation of the work is to reveal the non-equilibrium adhesion mechanics of a disordered elastomeric protein (Squid ring teeth, SRT), its phase kinetics as solid aggregates (similar to amyloids), and physical properties as colloidal suspensions (i.e., globular proteins). Most proteins adhere strongly to wet interfaces as monolayers (i.e., adhesive), but they are not known to be effective in chemically bonding together two substrates (i.e., cohesive as well as adhesive). Special proteins from marine organisms, such as blue mussels, acorn barnacles, sandcastle worms and freshwater caddisfly larva provide underwater adhesion due to modified amino acid chemistry or coacervation. Micro-scale roughness, crack trapping, wetting transitions also help the adhesion of land animals (e.g., adhesion of lizard or insects footpads). However, SRT does not function as adhesive in nature (i.e., it is a structural protein which strengthen the squid tentacles for holding the prey), and the adhesion mechanism of SRT could not be explained by equilibrium mechanics. Key aspects of the temperature effect on SRT, its adhesion mechanics based on nanoscale domain instability combined to surface chemistry will be discussed. December 9th, 2013 (03:35pm - 04:35pm) Seminar: Center for Dynamics and Geometry Seminar Title: Special representations of group actions and low complexity tilings of groups Speaker: Ayse Sahin, DePaul University Location: MB114 Generalizing a result of Alpern, Rudolph showed that the orbits of any measurable, measure preserving R^d action can be measurably tiled by 2^d rectangles and asked if this number of tiles is optimal. In joint work with B. Kra and A. Quas, we show that d+1 tiles suffice. Furthermore, for flows with completely positive entropy, this bound is optimal. December 10th, 2013 (10:10am - 11:00am) Seminar: Combinatorics/Partitions Seminar Title: Elementary Proofs of Congruences for the Cubic and Overcubic Partition Functions Speaker: James Sellers, PSU Location: MB106 In 2010, Hei-Chi Chan introduced the cubic partition function$a(n)$in connection with Ramanujan's cubic continued fraction. Among other things, Chan proved that, for all$n\geq 0,a(3n+2) \equiv 0 \pmod{3}.$In the same year, Byungchan Kim introduced the overcubic partition function$\overline{a}(n).$Using modular forms, Kim found a generating function representation for \overline{a}(3n+2) which implies that$\overline{a}(3n+2) \equiv 0 \pmod{6}$for all$n\geq 0.$More recently, Hirschhorn has proven Kim's generating function result using elementary generating function manipulations. In this talk, we use elementary means to prove functional equations satisfied by the generating functions for$a(n)$and$\overline{a}(n),$respectively. These lead to new representations of these generating functions as products of terms involving Ramanujan's$\psi$and$\varphi$functions. In the process, we are able to prove the congruences mentioned above as well as numerous arithmetic properties satisfied by$\overline{a}(n)\$ modulo small powers of 2 which do not appear in the literature.

December 10th, 2013 (03:30pm - 06:00pm)
Seminar: Working Seminar: Dynamics and its Working Tools
Title: Anosov flows on 3-manifolds, I.
Speaker: Thomas Barthelme, Penn State
Location: MB216
December 11th, 2013 (12:00pm - 01:30pm)
Seminar: Geometry Luncheon Seminar
Title: Generalizing Gauss's Linking Integral, and a surprising Hopf-like fibration
Speaker: Haggai Nuchi, U Penn
Location: MB114

I will discuss two topics. I'll describe a generalization of Gauss's Linking Integral to three-component links in Euclidean 3-space. I'll also describe a surprising new example of a fibration of S^3 x S^3 by great 3-spheres which is highly symmetric, and yet is not the restriction of a Hopf fibration of the 7-sphere.

December 12th, 2013 (11:15am - 12:05pm)
Seminar: Algebra and Number Theory Seminar
Title: The story of a "strange" function
Location: MB106

In a 1997 Fields Medalist Maxim Kontsevich suggested that the function F(q) = 1 + (1-q) + (1-q)(1-q^2) + (1-q)(1-q^2)(1-q^3)+..., defined only for q a root of unity, is similar to certain functions arising from the computation of Feynman integrals in quantum field theory. In the last sixteen years this function has been connected to interval orders in decision making theory, ascent sequences and matchings in combinatorics, and Vassiliev invariants in knot theory. Don Zagier related the asymptotic properties of this function to the "half-derivatives" of modular forms and was led to define a notion of "quantum modular form". In a trilogy of papers, my collaborators (Andrews, Bryson, Ono, Pitman, Zwegers) and I have connected this function to Ramanujan's mock theta functions and the combinatorics of unimodal sequences. I will tell the story of this function and these many relationships.

December 12th, 2013 (03:35pm - 04:25pm)
Seminar: Department of Mathematics Colloquium
Title: Regularity, long-time behavior and absence of anomalous dissipation of energy for the forced 2D Surface Quasigeostrophic Equation
Speaker: Peter Constantin, Princeton University
Location: MB114

I will start by presenting general issues concerning anomalous dissipation of energy in hydrodynamic models. Then I will introduce the SQG equation and describe two results concerning forced SQG: one in which a general abstract method is employed to prove absence of anomalous dissipation of energy, and the second in which a new proof of regularity is used to deduce finite dimensional long time behavior.

December 12th, 2013 (05:00pm - 06:30pm)
Seminar: SIAM Student Chapter Seminar
Title: TBA
Speaker: TBA
Location: MB106
Abstract: http://

TBA

December 19th, 2013 (05:00pm - 06:30pm)
Seminar: SIAM Student Chapter Seminar
Title: TBA
Speaker: TBA
Location: MB106
Abstract: http://

TBA


text:
# Which algorithm to use to solve this optimization problem?

• I have items called 'Resources' from 1 to 7.
• I have to use them in different actions identified from 1 to 10.
• I can do a maximum of 4 actions each time. This is called 'Operation'.
• The use of a resource has a cost of 1 per each 'Operation' even if it is used 4 times.
• The following table indicates the resources needed to do the related actions:
|        |            Resources             |
|--------|----------------------------------|
| Action |  1 |  2 |  3 |  4 |  5 |  6 |  7 |
|--------|----------------------------------|
|     1  |  1 |  0 |  1 |  1 |  0 |  0 |  0 |
|     2  |  1 |  1 |  0 |  0 |  1 |  0 |  0 |
|     3  |  1 |  0 |  1 |  0 |  0 |  1 |  0 |
|     4  |  0 |  1 |  0 |  0 |  0 |  0 |  0 |
|     5  |  1 |  0 |  1 |  1 |  0 |  1 |  0 |
|     6  |  1 |  1 |  1 |  0 |  0 |  0 |  0 |
|     7  |  0 |  1 |  0 |  0 |  0 |  0 |  0 |
|     8  |  1 |  0 |  1 |  0 |  1 |  0 |  0 |
|     9  |  0 |  1 |  0 |  1 |  0 |  0 |  0 |
|    10  |  1 |  1 |  1 |  0 |  0 |  0 |  1 |

The objective is to group all the 'Actions' in 'Operations' that minimize the total cost. For example, a group composed by actions {3, 7, 9} needs the resources {1, 2, 3, 4, 6} and therefore has a cost of 5, but a group composed by actions {4, 7, 9} needs the resources {2, 4} and therefore has a cost of 2.

It is needed to get done all the actions the most economically.

Which algorithm can solve this problem?

• Is the objective to perform each action at least once? ( in one of the groups) – Miguel Saraiva Jan 7 '20 at 14:09
• Exactly one time all the actions – Joracosu Jan 7 '20 at 14:11
• If the problem is the size of the table you showed or not much bigger the best way is probably brute forcing it. What is the real size of the problem? – Miguel Saraiva Jan 7 '20 at 14:14
• 30 actions with 10 resources grouped in a max of 6. Only the group of 6 are 4.000.000.000 combinations, but there are also other size combinations... I couldn't calculate it but probable huge – Joracosu Jan 7 '20 at 14:23
• It is not that big, 30 combinations 6 is 600k, then you do the same for 30 combination 5 etc it's around 1M total. Then you just do planning, I think it is pretty feasable, I can try to write something to help you out. You don't need to count in the resources in the combinations, you just verify it during planning and count up the total cost. – Miguel Saraiva Jan 7 '20 at 14:52

A possible approach would be starting by grouping the actions into all possible groups. For 30 actions grouped in a maximum of 6 this would mean: $$C^{30}_6 + C^{30}_5 + C^{30}_4 + C^{30}_3 + C^{30}_2 + C^{30}_1 = 768 211$$ Operations.

Then, I would define the constraints to simplify the problem, as in a Constraint Satisfaction Problem (CSP). The main constraint that you have is that one action can only be represented in one Operation. So, if you choose 1 of the 768ks operations to start with, the second option will be restricted by the condition.

Then I would do some sort of planning and sum the costs until the end doing a depth-first search. Whenever I find a total cost better the previous best, you would update the best value. (Remember that the search ends when between all the operations used, all the actions were explored once.)

While doing the search the costs are added up on the go. You can precompute a vector with the same size as the number of operations where each value corresponds to the total cost of the operation, and then sum it as you are going down the path.

You should also add some heuristic to prevent checking the same operations in different orders. For example doing operating [2,3,4] followed by [7,10], where each number represents an action, is the same as doing: [7,10] followed by [2,3,4].

I have finally abandoned the idea of doing it with an exact method and I have passed to the heuristic. I have mixed multi-boot, local search and certain random movements. Apparently this is called Greedy Randomized Adaptative Search Procedures (GRASP)

Hypothesis: the best solution is reached filling the 'operations' with the maximum of 'Actions' per 'Operation'. Other combinations are more expensive

1. create a random solution
[[1 2 3 4] [5 6 7 8] [9 10]]

2. calculate the cost of each 'Operation'
[[6] [6] [5]] == 17

3. Study the posibility of minimize the lower 'Operation' permuting some 'Action' with the other 'Operations'.
Actions 4 & 7 permute with 9 & 10
[[1 2 3 9] [5 6 10 8] [4 7]]

4. Calculate the new cost
[[6] [7] [1]] == 14

5. Repeat steps 2 to 4 until it is not possible to minimize the lower, then the second lower, then the third etc

6. You will find soon a Local Minimum. If no more moves are allowed but the Local Minimum is not the Global Minimum, permute two random 'actions' between two random 'operations' and repeat the steps 2º to 5º.

With this method it is possible to find very fast a solution adjusted to the minimum global cost with a complexity of O(n·log(n)), where n is the amount of 'actions'

I've tested it with a random sample of 60 'actions' and 26 'resources' grouped in 'operations' of 6 'actions'. It toke arround 5 minutes to get a really good solution arround 40% better that the initial one (*), and 30 minutes after it only got better solution in about 1%

(*) the initial solution was not actually a random solution. Instead of that I used 'Ant Colony' algorithm with 15 ants to get a better initial solution and reduce the amount of iterations, but that is another history


text:
# What volume of a 2.5 M stock solution of acetic acid is required to prepare 100.0 milliliters of a .50 M acetic acid solution?

Aug 22, 2016

$20. \text{milliliters}$ of acetic acid is required

#### Explanation:

Whenever you are dealing with a dilution, (going from a higher concentration to a lower concentration), you can use the equation below:

Let's determine our known and unknown variables:

color(blue)("Knowns:"

color(orange)("Unknowns:"

• Initial Volume

Next, we rearrange the equation to solve for ${V}_{1}$ by dividing by ${M}_{1}$ on both sides of the equation:

${V}_{1} = \frac{{M}_{2} \times {V}_{2}}{M} _ 1$

Plug in the known values and solve for your unknown:
${V}_{1} = \left(0.50 \cancel{\text{M"xx100.0mL)/(2.5cancel"M}}\right)$

Therefore,

${V}_{1} = 20. m L$


text:
# Why don't dispersions like median deviation and mode deviation exists on the lines of mean deviation?

Or to say in the formula MD=$\frac{1}{N}\sum_{i=1}^{N}|x_i-\overline{x}|$ why can't we have median or mode instead of mean($\overline{x}$) and as a result speak about additional possible measures of deviation?

Yes we can, there is, for example, median absolute deviation (MAD):

$$\operatorname{MAD}(X) = \operatorname{median}\left(\ \left| X_{i} - \operatorname{median} (X) \right|\ \right)$$

It has even some nice properties, e.g. $1.4826 \times \operatorname{MAD}(X)$ is estimator for standard deviation of normally distributed $X$. You can read more about it in the paper by Rousseeuw and Croux (1993).

We often look at much more then mean of errors, e.g. quantiles of errors, like in standard output of summary(lm) in R:

Call:
lm(formula = mpg ~ ., data = mtcars)

Residuals:
Min      1Q  Median      3Q     Max
-3.4506 -1.6044 -0.1196  1.2193  4.6271

We also look at distributions of errors by plotting residuals and absolute errors etc.

It is not that commonly used because mean is more sensitive to outliers then median, and in most cases this is a desired property when talking about error measures.

Rousseeuw, P.J. and Croux, C. (1993). Alternatives to the median absolute deviation. Journal of the American Statistical Association. 88 (424): 1273–1283.

• by "on the lines" I meant something mathematically similar to mean deviation as written in the question details section. Here, median operation is used in the median absolute deviation and not the mean operation. – ankit Nov 25 '16 at 12:42
• @ankit check the last paragraph of my answer. Moreover, median of deviations from median has some nice properties that are absent in case of median deviation of mean -- why would you want to use it? – Tim Nov 25 '16 at 12:49
• On the page(en.wikipedia.org/wiki/…) I've discovered the same mathematical thing being performed over the examples as requested in the question. Are they called mean absolute deviation around median and mean absolute deviation around mode respectively? If yes then does it means that mean absolute deviation is of three types? KINDLY HELP ME TIM – ankit Nov 25 '16 at 12:58
• @ankit I guess you already answered yourself, didn't you? – Tim Nov 25 '16 at 13:29
• MAD was used by Gauss in 1816. – Nick Cox Nov 25 '16 at 15:21


text:
# Draw the graphs of the equation 5x – y = 5 and 3x – y = 3. Determine the coordinates of the vertices of the triangle formed by these lines and the y-axis.

## Solution :

The given linear equations are

5x – y = 5           ………(1)

3x – y = 3            ………(2)

From equation (1),   y = 5x – 5

When x = 1, y = 5 – 5 = 0

When x = 2, y = 10 – 5 = 5

From equation (2), y = 3x – 3

When x = 0, y = -3

When x = 2, y = 3

Now, plot the above points on the graph, we get two lines.

We see that the line meets y-axis, the value of x is 0. In the equation 5x – y = 5, for x = 0, we get y = – 5.

Thus, the line 5x – y = 3 meets the y-axis at (0, -5).

and the line 3x – y = 3 meets the y-axis at (0, -3).

Thus, the coordinates of $$\triangle$$ ACE formed by these two lines and the y-axis A(1, 0), C(0, – 3) and E(0, -5).


text:
Categories:

System Functions (System Information)

Arguments¶

pipe_name

Pipe for which you want to retrieve the current status.

Usage Notes¶

• Returns results only for the pipe owner (i.e. the role with the OWNERSHIP privilege on the pipe) or a role with the MONITOR privilege on the pipe.

• pipe_name is a string so it must be enclosed in single quotes:

• Note that the entire name must be enclosed in single quotes, including the database and schema (if the name is fully-qualified), i.e. '<db>.<schema>.<pipe_name>'.

• If the pipe name is case-sensitive or includes any special characters or spaces, double quotes are required to process the case/characters. The double quotes must be enclosed within the single quotes, i.e. '"<pipe_name>"'.

Output¶

The function returns a JSON object containing the following name/value pairs (if applicable to the current pipe status):

Where:

executionState

Current execution state of the pipe. The value could be any one of the following:

• RUNNING (i.e. everything is normal; Snowflake may or may not be actively processing files for this pipe)

• STOPPED_CLONED (i.e. the pipe is contained by a database or schema clone)

• STOPPED_FEATURE_DISABLED

• STOPPED_STAGE_DROPPED

• STOPPED_FILE_FORMAT_DROPPED

• STOPPED_NOTIFICATION_INTEGRATION_DROPPED

• STOPPED_MISSING_PIPE

• STOPPED_MISSING_TABLE (the target table defined in the pipe definition was dropped)

• STALLED_COMPILATION_ERROR

• STALLED_INITIALIZATION_ERROR

• STALLED_EXECUTION_ERROR

• STALLED_INTERNAL_ERROR

• PAUSED

• PAUSED_BY_SNOWFLAKE_ADMIN

• PAUSED_BY_ACCOUNT_ADMIN

oldestFileTimestamp

Earliest timestamp among data files currently queued (if applicable), where the timestamp is set when the file is added to the queue.

pendingFileCount

This count can increase even if a pipe is paused. Depending on the AUTO_INGEST setting for the pipe, the number of queued files can increase as follows:

AUTO_INGEST = TRUE

Files added to the cloud storage bucket or container trigger new file event notifications for the pipe.

Note that if a paused pipe becomes stale, the pendingFileCount count ignores any event notifications older than the limited retention period.

AUTO_INGEST = FALSE

Calls to the insertFiles REST endpoint trigger files to be queued for loading by the pipe.

notificationChannelName

Amazon SQS queue or Microsoft Azure storage queue associated with the pipe.

numOutstandingMessagesOnChannel

Number of messages in the queue that have been queued but not received yet.

lastReceivedMessageTimestamp

Timestamp of the last message received from the queue. Note that this message might not apply to the specific pipe, e.g., if the path/prefix associated with the message does not match the path/prefix in the pipe definition. In addition, only messages triggered by created data objects are consumed by auto-ingest pipes.

lastForwardedMessageTimestamp

Timestamp of the last “create object” event message with a matching path/prefix that was forwarded to the pipe.

channelErrorMessage

Error message produced when attempting to read messages from the associated Google Cloud Pub/Sub queue or Microsoft Azure Event Grid storage queue.

lastErrorRecordTimestamp

Timestamp of last channel error message (i.e. error message reported in the channelErrorMessage value).

error

Error message produced when the pipe was last compiled for execution (if applicable); often caused by problems accessing the necessary objects (i.e. table, stage, file format) due to permission problems or dropped objects.

fault

Most recent internal Snowflake process error (if applicable). Used primarily by Snowflake for debugging purposes.

Examples¶

Retrieve the status for a pipe with a case-insensitive name:

SELECT SYSTEM$PIPE_STATUS('mydb.myschema.mypipe'); +---------------------------------------------------+ | SYSTEM$PIPE_STATUS('MYDB.MYSCHEMA.MYPIPE')        |
|---------------------------------------------------|
| {"executionState":"RUNNING","pendingFileCount":0} |
+---------------------------------------------------+

Retrieve the status for a pipe with a case-sensitive name:

SELECT SYSTEM$PIPE_STATUS('mydb.myschema."myPipe"'); +---------------------------------------------------+ | SYSTEM$PIPE_STATUS('MYDB.MYSCHEMA."MYPIPE"')      |
|---------------------------------------------------|
| {"executionState":"RUNNING","pendingFileCount":0} |
+---------------------------------------------------+


text:
1. ## Closed Sets

Suppose f:R->R is continuous and define the zero set of f by Z(f)={x: f(x)=0}.
Prove that Z(f) is a closed set. Give an example of a discontinuous function whose zero set is not closed.


text:
# Ngô Quốc Anh

## March 18, 2010

### Green’s function for viscous Burgers type equation, 2

Filed under: PDEs — Tags: — Ngô Quốc Anh @ 15:47

Followed by a question posted here we are now interested in how can we find the Green function for the following problem

$u_t+au_x-u_{xx}=0, \quad x>0$

where $a$ a constant and with boundary condition $u(0,t)=0$.

Note that, for heat equation, in one variable, the Green’s function is a solution of the initial value problem

$u_t-u_{xx}=0$

with boundary condition

$\displaystyle u(x,0)=\delta(x)$

where $\delta$ is the Dirac delta function and this Green function is already known as

$\displaystyle G(x,y,t) = \frac{1}{{\sqrt {4\pi at} }}{e^{ - \frac{{{{(x - y)}^2}}}{{4at}}}}$.

Note that, the Green’s function for heat equation in the whole line $\mathbb R$

$u_t-u_{xx}=0$

is

$\displaystyle G_a(x,y,t) = \frac{1}{{\sqrt {4\pi at} }}{e^{ - \frac{{{{(x - y)}^2}}}{{4at}}}}$.

However, this is not true once we restrict ourselves to the half-plan

$u_t-u_{xx}=0, \quad x>0$

with boundary condition

$\displaystyle u(x,0)=0$.

In order to find the correct one, we need to use the so-called reflection principle as follows: For each $x>0$, we define $\widetilde x =- x$, called the inverse point of $x$. It can be readily verified that the function

$\displaystyle G(x,y,t)=G_a(x,y,t)-G_a(x,\widetilde y,t)$

which implies

$\displaystyle G(x,y,t) = \frac{1}{{\sqrt {4\pi at} }}\left( {{e^{ - \frac{{{{(x - y)}^2}}}{{4at}}}} - {e^{ - \frac{{{{(x + y)}^2}}}{{4at}}}}} \right)$.

Now let us go back to the viscous Burgers type equation. By the following change of variable

$\displaystyle v = {e^{ - \frac{a}{2}x}}u$

one easily sees that

$\displaystyle\begin{gathered} {v_t} = {e^{ - \frac{a}{2}x}}{u_t} \hfill \\ {v_x} = - \frac{a}{2}{e^{ - \frac{a}{2}x}}u + {e^{ - \frac{a}{2}x}}{u_x} \hfill \\ {v_{xx}} = \frac{{{a^2}}}{4}{e^{ - \frac{a}{2}x}}u - a{e^{ - \frac{a}{2}x}}{u_x} + {e^{ - \frac{a}{2}x}}{u_{xx}} \hfill \\ \end{gathered}$

which gives

$\displaystyle\begin{gathered} {v_t} + \frac{{{a^2}}}{4}v - {v_{xx}} = {e^{ - \frac{a}{2}x}}{u_t} + \frac{{{a^2}}}{4}{e^{ - \frac{a}{2}x}}u - \frac{{{a^2}}}{4}{e^{ - \frac{a}{2}x}}u + a{e^{ - \frac{a}{2}x}}{u_x} - {e^{ - \frac{a}{2}x}}{u_{xx}} \hfill \\ \qquad\qquad= {e^{ - \frac{a}{2}x}}{u_t} + a{e^{ - \frac{a}{2}x}}{u_x} - {e^{ - \frac{a}{2}x}}{u_{xx}} \hfill \\ \qquad\qquad= 0 \hfill \\ \end{gathered}$.

In order to eliminate the term $\frac{a^2}{2}v$, we use the following change of variable

$\displaystyle w = {e^{\frac{{{a^2}}}{4}t}}v$

we obtain

$\displaystyle\begin{gathered} {w_t} = \frac{{{a^2}}}{4}{e^{\frac{{{a^2}}}{4}t}}v + {e^{\frac{{{a^2}}}{4}}}{v_t} \hfill \\ {w_x} = {e^{\frac{{{a^2}}}{4}t}}{v_x} \hfill \\ {w_{xx}} = {e^{\frac{{{a^2}}}{4}t}}{v_{xx}} \hfill \\ \end{gathered}$

which yields

$\displaystyle {w_t} - {w_{xx}} = \frac{{{a^2}}}{4}{e^{\frac{{{a^2}}}{4}t}}v + {e^{\frac{{{a^2}}}{4}t}}{v_t} - {e^{\frac{{{a^2}}}{2}t}}{v_{xx}} = {e^{\frac{{{a^2}}}{2}t}}\left( {{v_t} + \frac{{{a^2}}}{4}v - {v_{xx}}} \right) = 0$.

Hence we have the following summary

$\displaystyle {u_t} + a{u_x} - {u_{xx}} = 0\xrightarrow{{v = {e^{ - \frac{a}{2}x}}u}}{v_t} + \frac{{{a^2}}}{4}v - {v_{xx}} = 0\xrightarrow{{w = {e^{\frac{{{a^2}}}{4}t}}v}}{w_t} - {w_{xx}} = 0$.

We are now in a position to talk about the most interesting point of this entry: How to find the Green function for backward once we already have the Green function for pushforward? It is obvious to see that the boundary condition doesn’t change, i.e.

$\displaystyle w(0,t) = v(0,t) = u(0,t) = 0$.

The Green function for the last equation is already known, called

$\displaystyle {G_w}(x,y,t) = \frac{1}{{\sqrt {4\pi t} }}\left( {{e^{ - \frac{{{{(x - y)}^2}}}{{4t}}}} - {e^{ - \frac{{{{(x + y)}^2}}}{{4t}}}}} \right)$.

The Green function for the equation for $v$ can be constructed by looking at the substitution used. Precisely,

$\displaystyle {G_v}(x,y,t) = {e^{ - \frac{{{a^2}}}{4}t}}\frac{1}{{\sqrt {4\pi t} }}\left( {{e^{ - \frac{{{{(x - y)}^2}}}{{4t}}}} - {e^{ - \frac{{{{(x + y)}^2}}}{{4t}}}}} \right)$.

The Green function for the equation for $u$ is constructed a little bit crazy, what we need is the following

$\displaystyle {G_u}(x,y,t) = {e^{\frac{a}{2}(x - y)}}{e^{ - \frac{{{a^2}}}{4}t}}\frac{1}{{\sqrt {4\pi t} }}\left( {{e^{ - \frac{{{{(x - y)}^2}}}{{4t}}}} - {e^{ - \frac{{{{(x + y)}^2}}}{{4t}}}}} \right)$.

The most important property one should check is the boundary condition, roughly speaking, the Green function must satisfy

$\displaystyle G(x,0,t)=0$.

Advertisements

## 1 Comment »

1. It is nice. Thanks.

Comment by TTT — March 18, 2010 @ 17:36