Lrsinterface

lrsInputHalfspace(A, D, filename, positivity, inequality, a, d, f, sh)[source]

Outputs a file for lrs to convert an H-representation (half-space) of a polyhedron to a V-representation (vertex / ray) via vertex enumeration

USAGE

lrsInputHalfspace (A, D, filename, positivity, inequality, a, d, f, sh)

INPUTS
  • A – matrix of linear equalities \(A x =(a)\)

  • D – matrix of linear inequalities \(D x \geq (d)\)

  • filename – base name of output file

OPTIONAL INPUTS
  • positivity – {0, (1)} if positivity == 1, then positive orthant base

  • inequality – {0, (1)} if inequality == 1, then use two inequalities rather than a single equaltiy

  • a – boundary values for matrix of linear equalities \(A x = a\)

  • d – boundary values for matrix of linear inequalities \(D x \geq d\)

  • f – linear objective for a linear optimization problem in rational arithmetic

    minimise \(f^T x\), subject to \(A x = (a)\), \(D x \geq (d)\)

  • sh – {(0), 1} if sh == 1, output a shell script for submitting qsub job

lrsOutputReadRay(filename)[source]

Reads into matlab a vertex representation output from lrs

USAGE

[R, V] = lrsOutputReadRay (filename)

INPUT

filename – name of .ext file from lrs

OUTPUT
  • RnDim by nRay matrix of extreme rays

  • VnDim by nVertex matrix of vertices

lrsReadHalfspace(modelName, param)[source]

Read in a halfspace representation (*.ine) of a polytope derived from lrs See http://cgm.cs.mcgill.ca/~avis/C/lrslib/USERGUIDE.html#file

H-representation,

m is the number of input rows, each being an inequality or equation. n is the number of input columns and d=n-1 is the dimension of the input. An inequality or equation of the form:

b + a_1 x_1 + … + a_d x_d >= 0

b + a_1 x_1 + … + a_d x_d = 0

is input as the line:

b a_1 … a_d

The coefficients can be entered as integers or rationals in the format x/y. To distinguish an equation a linearity option must be supplied before the begin line (see below).

INPUT modelName string giving the prefix of a *.ine file

It is assumed the file is pwd/*.ine, otherwise provide the full path

OUTPUT

A: m x n left hand side matrix of linear system:math:A x <=> (b) b: m x 1 right hand side vector of linear system \(A x <=> (b)\) csense: m x 1 character array of constraint senses, one for each row in A

must be either (‘E’, equality, ‘G’ greater than, ‘L’ less than).

EXAMPLE file test H-representation nonnegative begin 14 10 integer 0 -1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 -1 0 0 0 1 -2 -2 0 0 0 0 0 0 0 -1 2 2 0 0 0 0 0 0 0 0 1 0 0 -1 -1 0 0 0 0 0 -1 0 0 1 1 0 0 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 -1 1 -1 0 0 0 0 0 0 0 0 1 0 1 0 -1 0 0 0 0 0 -1 0 -1 0 1 0 0 0 1 1 0 0 0 0 0 -1 0 0 -1 -1 0 0 0 0 0 1 0 0 0 -1 1 -1 0 0 0 0 0 0 0 1 -1 1 0 0 0 0 end

lrsReadRay(modelName, param)[source]

Read in a vertex representation (*.ext) of a polytope derived from lrs See http://cgm.cs.mcgill.ca/~avis/C/lrslib/USERGUIDE.html#file

USAGE

[Q, vertexBool, fileNameOut] = lrsReadRay (modelName,param)

INPUT: modelName string giving the prefix of the *.ext file that will contain the vertex representation

It is assumed the file is pwd/*.ine, otherwise provide the full path.

OPTIONAL INPUT
  • param – parameter structure with the following fields:

  • *.positivity – if equals to 1, then positive orthant base

  • *.inequality – if equals to 1, then represent as two inequalities rather than a single equality

  • *.shellScript – if equals to 1, then lrs is run through a bash script

  • *.redund if equals to 0, then remove redundant linear equalities

OUTPUT: Q m x n integer matrix where each row is a variable and each column is a vertex or ray vertexBool n x 1 Boolean vector indicating which columns of Q are vertices

By default, all columns of Q are assumed to be rays.

Ronan Fleming 2021

lrsRun(modelName, param)[source]

Runs lrs in the command line either using a shell script or launched directly from within Matlab.

USAGE

fileNameOut = runLrs (modelName, positivity, inequality, shellScript)

INPUTS
  • modelName – name of the file to give as input to lrs

  • param – parameter structure with the following fields:

  • *.positivity – if equals to 1, then positive orthant base

  • *.inequality – if equals to 1, then represent as two inequalities rather than a single equality

  • *.shellScript – if equals to 1, then lrs is run through a bash script

  • *.redund if equals to 0, then remove redundant linear equalities

OUTPTS fileNameOut full path to output file

lrsSpecifyRows(fileNameIn)[source]

read the number of rows of data in the file and replace the **** with the number of rows

lrsWriteHalfspace(A, b, csense, modelName, param)[source]

Outputs a file for lrs to convert an H-representation (half-space) of a polyhedron to a V-representation (vertex / ray) via vertex enumeration

USAGE

lrsWriteHalfspace (A, b, csense, modelName, param)

INPUTS

A – m x n matrix of linear constraints \(A x (csense) b\)

OPTIONAL INPUTS
  • b – m x 1 rhs of linear constraints

  • csense – m x 1 char with (‘E’),’G’ or ‘L’

  • modelName – name of the model to be used when generating filenames, ‘model’ by default

  • param.positivity – {0, (1)} if positivity == 1, then positive orthant base

  • param.inequality – {0, (1)} if inequality == 1, then use two inequalities rather than a single equaltiy

lrsWriteRay(Q, modelName, vertexBool, param)[source]

Outputs a file for lrs to convert an V-representation (vertex / ray) of a polyhedron to a H-representation (half-space) via facet enumeration

V-representation:

m is the number of input rows, each being a vertex, ray or line. n is the number of input columns and d=n-1 is dimension of the input. Each vertex is given in the form:

1 v_1 v_1 … v_d

Each ray is given in the form:

0 r_1 r_2… r_d

where r_1 … r_d is a point on the ray.

There must be at least one vertex in each file. For bounded polyhedra there will be no rays entered. The coefficients can be entered as integers or rationals in the format x/y. An input line can be specified as a ray and then included in the linearity option (see below).

INPUT Q m x n integer matrix where each row is a variable and each column is a vertex or ray modelName string giving the prefix of the *.ext file that will contain the vertex representation

It is assumed the file is pwd/*.ine, otherwise provide the full path.

OPTIONAL INPUT vertexBool n x 1 Boolean vector indicating which columns of Q are vertices

By default, all columns of Q are assumed to be rays.

param: parameter structure with the following fields:

*.positivity: if equals to 1, then positive orthant base *.inequality: if equals to 1, then represent as two inequalities rather than a single equality *.shellScript: if equals to 1, then lrs is run through a bash script *.redund if equals to 0, then remove redundant linear equalities