[Coin-discuss] CoinModel (more sophisticated version of CoinBuild)

John J Forrest jjforre at us.ibm.com
Wed Feb 16 17:18:38 EST 2005


I was glad to hear that using CoinBuild Brady Hunsaker, François Galea and 
David Wright got better performance so I have developed a CoinModel class 
which has more flexibility and is about as fast when used in a similar way 
to CoinBuild.  You can still pass the data across to Clp or Osi by addRows 
or addColumns but you also have the possibility of loading the entire 
problem with loadProblem.

A big disadvantage of CoinBuild was that you could add rows or add columns 
but not both which lacked flexibility and meant that the other dimension 
had to be created in a non-intuitive way.  CoinModel is a complete 
representation of the data input to the model including names and integer 
information.  So apart from using addRow or addColumn you can set the 
upper bound on column 1000 to 20 and not care how many columns there are 
at present.  You can set any element in the model by 
model.setElement(row,column,value) in a reasonably efficient manner.  You 
can traverse the nonzero values in any row or column etc.

To make it a bit more interesting I also allow strings as well as doubles. 
 So you can set an objective coefficient to 2.0+value1*0.3 and an element 
to -value1.  Then to solve that model for values 0.0 to 10.0 by 1.0 using 
an OsiSolverInterface model would be:

for (double value = 0.0; value<=10.0 ; value ++) {
  buildObject.associateElement("value1",value);
  model.loadProblem(buildObject);
  model.resolve();
}

I am not sure how useful that is - it just made it more interesting and I 
may try and write some interactive tool for model editing.  It could be 
useful for some iterative algorithms

The code is involved in several unit tests and sample coding can be found 
in Clp/Samples/add*.cpp.  The functionality is available for Clp and Osi. 
I have left CoinBuild for simpler applications as it is simpler and 
slightly faster.

John Forrest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20050216/724cfcdb/attachment.html>


More information about the Coin-discuss mailing list