[OS] Understanding linearConstraintCoefficients markups

Horand Gassmann Horand.Gassmann at Dal.Ca
Tue Feb 12 12:28:09 EST 2008


Quoting Joe <joe.boublack at gmail.com>:

>
>
> I'm trying to convert my lp_solve/LP files into OSiL file format. I
> don't understand the mapping applied on coefficients from
> linearConstraintCoefficients markups. I've found one example in the
> "OS 1.0 User's Manual" also discussed in this newsgroup. However these
> explanations is not so clear for me. I've also checked examples from
> documentations of LPFML because OSiL would be a superset of this
> language (unfortunately, markups names have been changed from LPFML to
> OSiL conventions).
>
> Maybe someone could help me to convert a small (only 4 variables, 2
> constraints, 1 objective) lp_solve/file into OSiL (the contents of
> small.lp is paste on the end of this message). Please find my attempt
> for OSiL formulation (actually, OSSolverService crashes on parsing
> this file) :

Several things: Order matters. Among the children of <instanceData>, the
<variables> element has to come first. And there is only one element named
<linearConstraintCoefficients>. It contains the entire constraint matrix,
either in row or in column format. It might be easier at first to follow the
example in row format.

#broken-small.osil ; usage : OSSolverService -osil broken-small.osil
<?xml version='1.0' encoding='UTF-8'?>
<osil xmlns='os.optimizationservices.org'>
<instanceHeader>
  <name>My broken example</name>
  <source>Manually written</source>
  <description>Any comments</description>
</instanceHeader>

<!-- Declarations -->
<variables numberOfVariables='4'>
<var name='X0' type='I'/>
<var name='X1' type='I'/>
<var name='X2' type='I'/>
<var name='X3' type='I'/>
</variables>

<!-- Objective -->
<objectives numberOfObjectives='1'>
<obj name='Example objective' maxOrMin='max'  numberOfObjCoef='1'>
  <coef idx='3'>1</coef>
</obj>
</objectives>

<!-- Constraints -->
<constraints numberOfValues='2'>
<con ub='0' lb='0'/>
<con ub='100'/>
</constraints>

<linearConstraintCoefficients numberOfValues='7'> <!-- 7 nonzeroes -->

<!-- the first row has four nonzeroes, the second three: -->

<start>
   <el>0</el>   <el>4</el>   <el>7</el>
</start>

<colIdx>
  <el>0</el>  <el>1</el>  <el>2</el>  <el>3</el>   <!-- row 0 -->
  <el>0</el>  <el>1</el>  <el>2</el>               <!-- row 1 -->
</colIdx>

<value>
  <el>-2</el>  <el>-3</el>  <el>-5</el>  <el>7</el>   <!-- row 0 -->
  <el>1</el>  <el>1</el>  <el>1</el>                  <!-- row 1 -->
</value>
</linearConstraintCoefficients>
</instanceData>
</osil>


If you want to give the <linearConstaintCoefficients> element columnwise, you
would specify:

<linearConstraintCoefficients numberOfValues='7'>

<!-- the first three columns have two nonzeroes, the last one only one: -->

<start>
   <el>0</el>   <el>2</el>     <el>4</el>   <el>6</el>   <el>7</el>
</start>

<rowIdx>
  <el>0</el>   <el>1</el>          <!-- col 0 -->
  <el>0</el>   <el>1</el>          <!-- col 1 -->
  <el>0</el>   <el>1</el>          <!-- col 2 -->
  <el>0</el>                       <!-- col 3 -->
</rowIdx>

<value>
  <el>-2</el>  <el>1</el>          <!-- col 0 -->
  <el>-3</el>  <el>1</el>          <!-- col 1 -->
  <el>-5</el>  <el>1</el>          <!-- col 2 -->
  <el>7</el>                       <!-- col 3 -->
</value>
</linearConstraintCoefficients>


HTH

gus gassmann





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Optimization Services (OS)" group.
To post to this group, send email to optimizationservices at googlegroups.com
To unsubscribe from this group, send email to optimizationservices-unsubscribe at googlegroups.com
For more options, visit this group at http://groups.google.com/group/optimizationservices?hl=en
-~----------~----~----~----~------~----~------~--~---



More information about the OS mailing list