Coverage Report - net.sourceforge.combean.graph.alg.lp.LPModelSolverAsFixedDoubleEdgeMap
 
Classes in this File Line Coverage Branch Coverage Complexity
LPModelSolverAsFixedDoubleEdgeMap
100%
9/9
N/A
1
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 30.08.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.graph.alg.lp;
 23  
 
 24  
 import net.sourceforge.combean.interfaces.graph.Edge;
 25  
 import net.sourceforge.combean.interfaces.graph.containers.doubleval.FixedDoubleEdgeMap;
 26  
 import net.sourceforge.combean.interfaces.graph.prop.GlobalNumberedEdgesGraphProp;
 27  
 import net.sourceforge.combean.interfaces.mathprog.lp.model.LPModelSolver;
 28  
 import net.sourceforge.combean.mathprog.lp.model.LPModelIndexImpl;
 29  
 
 30  
 /**
 31  
  * Wrap a LP model modelSolver as fixed double edge map, which returns the primal
 32  
  * solution value for each edge.
 33  
  * 
 34  
  * This is useful for LPs where a part of the variables correspond to settings
 35  
  * for the edges in a graph.
 36  
  * 
 37  
  * @author schickin
 38  
  *
 39  
  */
 40  
 public class LPModelSolverAsFixedDoubleEdgeMap implements FixedDoubleEdgeMap {
 41  
     
 42  9
     private LPModelSolver modelSolver = null;
 43  
 
 44  9
     private GlobalNumberedEdgesGraphProp numberedEdges = null;
 45  9
     private String offsetId = null;
 46  
 
 47  
     /**
 48  
      * Constructor
 49  
      * 
 50  
      * @param solver the LP model modelSolver to be wrapped. The LP model must
 51  
      * contain the edges of the graph for which the edge map is accessed.
 52  
      * @param numberedEdges the graph to which the edge map refers.
 53  
      * @param offsetId the offset identifier for the columns in the LP model
 54  
      * which correspond to the edges in the given graph.
 55  
      */
 56  
     public LPModelSolverAsFixedDoubleEdgeMap(LPModelSolver solver,
 57  
             GlobalNumberedEdgesGraphProp numberedEdges,
 58  
             String offsetId) {
 59  9
         super();
 60  
         
 61  9
         this.modelSolver = solver;
 62  9
         this.numberedEdges = numberedEdges;
 63  9
         this.offsetId = offsetId;
 64  9
     }
 65  
     
 66  
     /* (non-Javadoc)
 67  
      * @see net.sourceforge.combean.interfaces.graph.containers.doubleval.FixedDoubleEdgeMap#getDouble(net.sourceforge.combean.interfaces.graph.Edge)
 68  
      */
 69  
     public double getDouble(Edge e) {
 70  45
          return this.modelSolver.getSolution(
 71  
                  new LPModelIndexImpl(
 72  
                          this.numberedEdges.getEdgeNumber(e), this.offsetId));
 73  
     }
 74  
 
 75  
 }