LPFML

LPFML is a modeling format in XML structure. It started as its own project but is now part of the bigger COIN-OR OSlL project

See https://www.coin-or.org/OS/OSlL.html for the home page of this tool and examples.

lp_solve can read/write and solve these LPFML models directly via the xli_LPFML XLI driver (see External Language Interfaces).

Reading LPFML models

It reads such a model in above format and can solve it then.

For example:
lp_solve -rxli xli_LPFML parinc.xml

This gives as result:

Value of objective function: 7667.94172245

Actual values of the variables:
x1                        539.984
x2                        252.011
Options

none

Generating LPFML models

The XLI can also create a LPFML model.

For example:

lp_solve model.lp -wxli xli_LPFML model.xml

This gives as model.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<mathProgram xmlns="http://FML/lpfml.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://FML/lpfml.xsd
 lpfml.xsd">

  <linearProgramDescription>
    <source></source>
    <maxOrMin>max</maxOrMin>
    <numberRows>4</numberRows>
    <numberVars>2</numberVars>
  </linearProgramDescription>

  <linearProgramData>
    <rows>
      <row rowName="cutanddye" rowUB="630"/>
      <row rowName="sewing" rowUB="600"/>
      <row rowName="finishing" rowUB="708"/>
      <row rowName="inspectandpack" rowUB="135"/>
    </rows>
    <columns>
      <col colName="x1" colType="C" objVal="10"/>
      <col colName="x2" colType="C" objVal="9"/>
    </columns>
    <amatrix>
      <sparseMatrix>
        <pntANonz>
          <el>4</el>
          <el>8</el>
        </pntANonz>
        <rowIdx>
          <el>0</el>
          <el>1</el>
          <el>2</el>
          <el>3</el>
          <el>0</el>
          <el>1</el>
          <el>2</el>
          <el>3</el>
        </rowIdx>
        <nonz>
          <el>0.7</el>
          <el>0.5</el>
          <el>1</el>
          <el>0.1</el>
          <el>1</el>
          <el>0.8333</el>
          <el>0.6667</el>
          <el>0.25</el>
        </nonz>
      </sparseMatrix>
    </amatrix>
  </linearProgramData>

</mathProgram>
Options

The XLI accepts several options:

  -b64
  -comp          Compress.
  -can           Canonical.

API

Use the lpsolve API call read_XLI to read a model and write_XLI to write a model. See also External Language Interfaces.

IDE

Also from within the IDE, this XLI can be used. However, some entries must be added in LpSolveIDE.ini (in the folder where the IDE is installed).

In the [XLI] section the following must be added:

lib4=xli_LPFML

And a new section for the LPFML XLI must also be added:

[xli_LPFML]
extension=.xml
language=XML

Then make sure that the xli_LPFML.dll is available for the IDE. This must be done by placing this dll in the IDE folder or in the Windows system32 folder. There are also 2 extra dlls needed: Xalan-C_1_6_0.dll and xerces-c_2_3_0.dll. It is advised to put these in the system32 folder

Example models

parinc.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Sample XML file generated by XMLSPY v5 U (http://www.xmlspy.com)-->
<!-- $Id: parinc.xml,v 1.8 2003/08/08 19:50:04 kipp Exp $ -->
<mathProgram xmlns="http://FML/lpfml.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://FML/lpfml.xsd
http://gsbkip.uchicago.edu/fml/testproblems/lpfml.xsd">

	<linearProgramDescription>
		<source>Par Inc. Problem from Anderson, Sweeny, and Williams</source>
	<maxOrMin>max</maxOrMin>
		<objConstant>0.</objConstant>
		<numberRows>4</numberRows>
		<numberVars>2</numberVars>
	</linearProgramDescription>
	<linearProgramData>
		<rows>
			<row rowName="cutanddye"  rowUB="630" />
			<row rowName="sewing" rowUB="600"/>
			<row rowName="finishing" rowUB="708"/>
			<row rowName="inspectandpack" rowUB="135" />
		</rows>
		<columns>
			<col objVal="10.0" colName="x1" colType="C" colLB="0.0" />
			<col objVal="9" colName="x2" colType="C" colLB="0.0" />
		</columns>
		<amatrix>
			<sparseMatrix>
				<pntANonz>
					<el>4</el>
					<el>8</el>
				</pntANonz>
				<rowIdx>
					<el>0</el>
					<el>1</el>
					<el>2</el>
					<el>3</el>
					<el>0</el>
					<el>1</el>
					<el>2</el>
					<el>3</el>
				</rowIdx>
				<nonz>
					<el>.7</el>
					<el>.5</el>
					<el>1.0</el>
					<el>0.1</el>
					<el>1.0</el>
					<el>0.8333</el>
					<el>0.6667</el>
					<el>0.25</el>
				</nonz>
			</sparseMatrix>
		</amatrix>
	</linearProgramData>
	<linearProgramSolution>
		<primalSolution>
			<sol idx="1" name="x1" val="540"/>
			<sol idx="2" name="x2" val="252"/>
		</primalSolution>
		<dualSolution>
			<sol idx="1" name="cutanddye" val="4.37457"/>
			<sol idx="3" name="finishing" val="6.9378"/>
		</dualSolution>
		<optimalValue>7667.94</optimalValue>
		<status statusId="optimalSolutionFound">Put in here any other status message desired</status>
		<solverMessage>This was solved using LINDO from LINDO Systems, Inc.</solverMessage>
	</linearProgramSolution>
</mathProgram>
model.lp
/* Objective function */
max: +10 x1 +9 x2;

/* Constraints */
cutanddye: +0.7 x1 +x2 <= 630;
sewing: +0.5 x1 +0.8333 x2 <= 600;
finishing: +x1 +0.6667 x2 <= 708;
inspectandpack: +0.1 x1 +0.25 x2 <= 135;