Creating Polymake Objects

The interaction with the polymake program is done via files. A PolymakeObject is mainly a pointer to a file and a list of known properties of the object. These properties need not be stored in the file. Whenever polymake is called, the returned value is read from standard output and stored in the PolymakeObject corresponding to the file for which polymake is called.

The files for polymake are written in the old (non-xml) format. The first run of polymake converts them into the new (xml) format. This means that changes to the file by means of the methods outlined below after the first run of polymake will probably lead to corrupted files.

nothing
Creates an empty file with name filename. Note that filename has to include the full path and the directory for the file must exist.
PolymakeObject

If called without arguments, this method generates an empty file in the directory defined by .

If a directory dir is given (this directory must exist), an empty file is generated in this directory. If prefix is not given, the file is called polyN where N is the current runtime. If a file of this name already exists, a number is appended separated by a dot (example: "poly1340" and "poly1340.1"). If prefix is given, the filename starts with this prefix.

Optionally, the file can be generated with a header specifying application, version and type of the object. This is done by passing the triple of strings appvertyp to . A valid triple is ["polytope","2.3","RationalPolytope"]. Validity is checked by .
bool
Checks if the triple arppvertyp of strings specifies an application and type of polymake version 2.3. More specifically, the first entry has to be an application from ["polytope","surface","topaz"] and the third entry has to be a type corresponding to the application given in the first entry. The second entry is not checked.
PolymakeObject

This method generates a PolymakeObject corresponding to the file filename in the directory dir. If dir is not given, the POLYMAKE&uscore;DATA&uscore;DIR is used.If no file with name filename exists in dir (or POLYMAKE&uscore;DATA&uscore;DIR, respectively), an empty file is created.

Note that the contents of the file do not matter for the generation of the object. In particular, the object does not know any of the properties that might be encoded in the file. The only way to transfer information from files to PolymakeObjects is via .

Accessing Properties of Polymake Objects

A PolymakeObject contains information about the directory of its file, the name of its file and about properties calculated by calling . The properties returned by the polymake program are stored under the name polymake assigns to them (that is, the name of the data block in the corresponding file).

The following methods can be used to access the information stored in a PolymakeObject. But be careful! All functions return the actual object. No copies are made. So if you change one of the returned objects, you change the PolymakeObject itself.

Directory
Returns the directory of the file associated with poly.
String
Returns the name of the file associated with poly. This does only mean the name of the file, not the full path. For the full path and file name see
String
Returns the file associated with the PolymakeObject poly with its complete path.
List of Strings
Returns a list of the names of all known properties. This does only include the properties returned by , "dir" and "filename" are not included. If no properties are known, fail is returned.
Record
Returns the record of all known properties. If no properties are known, fail is returned.
Returns the value of the property name if it is known. If the value is not known, fail is returned. name must be a String.
Example: Creating and Accessing Polymake Objects

Suppose the file /tmp/threecube.poly contains the three dimensional cube in polymake form. Now generate a PolymakeObject from this file and call to make the vertices of the cube known to the object.

### suppose we have a polymake file /tmp/threecube.poly ### containing a cube in three dimensions gap> cube:=CreatePolymakeObjectFromFile(Directory("/tmp"),"threecube.poly"); <polymake object. No properties known> gap> FilenameOfPolymakeObject(cube); "threecube.poly" gap> FullFilenameOfPolymakeObject(cube); "/tmp/threecube.poly" #nothing is known about the cube: gap> NamesKnownPropertiesOfPolymakeObject(cube); fail gap> Polymake(cube,"VERTICES"); [ [ -1, -1, -1 ], [ 1, -1, -1 ], [ -1, 1, -1 ], [ 1, 1, -1 ], [ -1, -1, 1 ], [ 1, -1, 1 ], [ -1, 1, 1 ], [ 1, 1, 1 ] ] # Now <cube> knows its vertices: gap> Print(cube); <polymake object threecube.poly. Properties known: [ "VERTICES" ]> gap> PropertyOfPolymakeObject(cube,"VERTICES"); [ [ -1, -1, -1 ], [ 1, -1, -1 ], [ -1, 1, -1 ], [ 1, 1, -1 ], [ -1, -1, 1 ], [ 1, -1, 1 ], [ -1, 1, 1 ], [ 1, 1, 1 ] ] gap> KnownPropertiesOfPolymakeObject(cube); rec( VERTICES := [ [ -1, -1, -1 ], [ 1, -1, -1 ], [ -1, 1, -1 ], [ 1, 1, -1 ], [ -1, -1, 1 ], [ 1, -1, 1 ], [ -1, 1, 1 ], [ 1, 1, 1 ] ] )
Writing to Polymake Objects
To transfer data from &GAP; to polymake, the following methods can be used. But bear in mind that none of these functions test if the resulting polymake file is still consistent.

nothing
This appends the string string to the file associated to the PolymakeObject poly. It is not tested if the string is syntactically correct as a part of a polymake file. It is also not tested if the string is compatible with the data already contained in the file.

INEQUALITIES, POINTS and VERTICES can be appended to a polymake object using the following functions:

nothing
Takes a list pointlist of vectors and converts it into a string which represents a polymake block labeled "POINTS". This string is then added to the file associated with poly. The "POINTS" block of the file associated with poly then contains points with leading ones, as polymake uses affine notation.
nothing
Does the same as AppendPointlistToPolymakeObject, but with "VERTICES" instead of "POINTS".
nothing
Just appends the inequalities given in ineqlist to the polymake object poly (with caption "INEQUALITIES"). Note that this does not check if an "INEQUALITIES" section does already exist in the file associated with poly.
String
This function takes a matrix matrix and converts it to a string. This string can then be appended to a polymake file via to form a block of data labeled name.

This may be used to write blocks like INEQUALITIES or FACETS.
nothing
Deletes all known properties of the PolymakeObject poly and replaces its file with an empty one.
If the triple of strings appvertyp specifying application, version and type (see ) is given, the file is replaced with a file that contains only a header specifying application, version and type of the polymake object.

There are also methods to manipulate the known values without touching the file of the PolymakeObject:

Takes the object data and writes it to the known properties section of the PolymakeObject poly. The string name is used as the name of the property. If a property with that name already exists, it is overwritten. Again, there is no check if data is consistent, correct or meaningful.
If the PolymakeObject poly has a property with name name, that property is unbound. If there is no such property, fail is returned.