Coverage Report - net.sourceforge.combean.mathprog.lp.DoubleLPVariable
 
Classes in this File Line Coverage Branch Coverage Complexity
DoubleLPVariable
54%
19/35
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 22.04.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.mathprog.lp;
 23  
 
 24  
 import net.sourceforge.combean.interfaces.mathprog.lp.LPVariable;
 25  
 
 26  
 /**
 27  
  * A linear variable with representation based on plain Java doubles.
 28  
  * 
 29  
  * @author schickin
 30  
  *
 31  
  */
 32  
 public class DoubleLPVariable implements LPVariable {
 33  
     
 34  450
     double coeff = 0.0;
 35  450
     double lowerBound = Double.NEGATIVE_INFINITY;
 36  450
     double upperBound = Double.POSITIVE_INFINITY;
 37  
     
 38  450
     String name = new String("");
 39  
 
 40  
     /**
 41  
      * Constructor for an unbounded variable.
 42  
      * 
 43  
      * @param coeff the coefficient in the objective function.
 44  
      */
 45  
     public DoubleLPVariable(double coeff) {
 46  0
         super();
 47  
         
 48  0
         this.coeff = coeff;
 49  0
     }
 50  
 
 51  
     /**
 52  
      * Constructor for a bounded variable
 53  
      * 
 54  
      * @param coeff the coefficient in the objective function.
 55  
      * @param lowerBound the lower bound of the variable
 56  
      * @param upperBound the upper bound of the variable
 57  
      */
 58  
     public DoubleLPVariable(double coeff,
 59  
             double lowerBound, double upperBound) {
 60  54
         super();
 61  
         
 62  54
         this.coeff = coeff;
 63  54
         this.lowerBound = lowerBound;
 64  54
         this.upperBound = upperBound;
 65  54
     }
 66  
 
 67  
     /**
 68  
      * Constructor for an unbounded variable.
 69  
      * 
 70  
      * @param name the name of the variable.
 71  
      * @param coeff the coefficient in the objective function.
 72  
      */
 73  
     public DoubleLPVariable(String name, double coeff) {
 74  0
         super();
 75  
         
 76  0
         this.name = name;
 77  0
         this.coeff = coeff;
 78  0
     }
 79  
 
 80  
     /**
 81  
      * Constructor for a bounded variable
 82  
      * 
 83  
      * @param name the name of the variable.
 84  
      * @param coeff the coefficient in the objective function.
 85  
      * @param lowerBound the lower bound of the variable
 86  
      * @param upperBound the upper bound of the variable
 87  
      */
 88  
     public DoubleLPVariable(String name, double coeff,
 89  
             double lowerBound, double upperBound) {
 90  396
         super();
 91  
         
 92  396
         this.name = name;
 93  396
         this.coeff = coeff;
 94  396
         this.lowerBound = lowerBound;
 95  396
         this.upperBound = upperBound;
 96  396
     }
 97  
 
 98  
     /* (non-Javadoc)
 99  
      * @see net.sourceforge.combean.interfaces.mathprog.lp.LPVariable#getCoeff()
 100  
      */
 101  
     public double getCoeff() {
 102  450
          return this.coeff;
 103  
     }
 104  
 
 105  
     /* (non-Javadoc)
 106  
      * @see net.sourceforge.combean.interfaces.mathprog.lp.LPVariable#getLowerBound()
 107  
      */
 108  
     public double getLowerBound() {
 109  516
          return this.lowerBound;
 110  
     }
 111  
 
 112  
     /* (non-Javadoc)
 113  
      * @see net.sourceforge.combean.interfaces.mathprog.lp.LPVariable#getUpperBound()
 114  
      */
 115  
     public double getUpperBound() {
 116  516
         return this.upperBound;
 117  
     }
 118  
 
 119  
     /* (non-Javadoc)
 120  
      * @see net.sourceforge.combean.interfaces.base.NamedObject#getName()
 121  
      */
 122  
     public String getName() {
 123  384
          return this.name;
 124  
     }
 125  
 
 126  
     /**
 127  
      * @param name The name to set.
 128  
      */
 129  
     public void setName(String name) {
 130  0
         this.name = name;
 131  0
     }
 132  
     
 133  
     public String toString() {
 134  0
         StringBuffer result = new StringBuffer();
 135  
         
 136  0
         result.append(getClass().getName() + " {");
 137  0
         result.append(" name '" + getName() + "'");
 138  0
         result.append(" coeff " + getCoeff());
 139  0
         result.append(" bounds [" + getLowerBound() + "," +
 140  
                 getUpperBound() + "]");
 141  0
         result.append("}");
 142  
         
 143  0
         return result.toString();
 144  
     }
 145  
 }