lemon/lp_base.h
changeset 579 d11bf7998905
parent 514 2eb5c8ca2c91
child 576 745e182d0139
equal deleted inserted replaced
5:8edf61fc8ebc 6:8c00fbe8700e
   916     };
   916     };
   917 
   917 
   918   protected:
   918   protected:
   919 
   919 
   920     //Abstract virtual functions
   920     //Abstract virtual functions
   921     virtual LpBase* _newSolver() const = 0;
       
   922     virtual LpBase* _cloneSolver() const = 0;
       
   923 
   921 
   924     virtual int _addColId(int col) { return cols.addIndex(col); }
   922     virtual int _addColId(int col) { return cols.addIndex(col); }
   925     virtual int _addRowId(int row) { return rows.addIndex(row); }
   923     virtual int _addRowId(int row) { return rows.addIndex(row); }
   926 
   924 
   927     virtual void _eraseColId(int col) { cols.eraseIndex(col); }
   925     virtual void _eraseColId(int col) { cols.eraseIndex(col); }
   984 
   982 
   985   public:
   983   public:
   986 
   984 
   987     /// Virtual destructor
   985     /// Virtual destructor
   988     virtual ~LpBase() {}
   986     virtual ~LpBase() {}
   989 
       
   990     ///Creates a new LP problem
       
   991     LpBase* newSolver() {return _newSolver();}
       
   992     ///Makes a copy of the LP problem
       
   993     LpBase* cloneSolver() {return _cloneSolver();}
       
   994 
   987 
   995     ///Gives back the name of the solver.
   988     ///Gives back the name of the solver.
   996     const char* solverName() const {return _solverName();}
   989     const char* solverName() const {return _solverName();}
   997 
   990 
   998     ///\name Build up and modify the LP
   991     ///\name Build up and modify the LP
  1819     virtual ProblemType _getPrimalType() const = 0;
  1812     virtual ProblemType _getPrimalType() const = 0;
  1820     virtual ProblemType _getDualType() const = 0;
  1813     virtual ProblemType _getDualType() const = 0;
  1821 
  1814 
  1822   public:
  1815   public:
  1823 
  1816 
       
  1817     ///Allocate a new LP problem instance
       
  1818     virtual LpSolver* newSolver() const = 0;
       
  1819     ///Make a copy of the LP problem
       
  1820     virtual LpSolver* cloneSolver() const = 0;
       
  1821 
  1824     ///\name Solve the LP
  1822     ///\name Solve the LP
  1825 
  1823 
  1826     ///@{
  1824     ///@{
  1827 
  1825 
  1828     ///\e Solve the LP problem at hand
  1826     ///\e Solve the LP problem at hand
  1933     ///- \ref NaN if no primal solution is found.
  1931     ///- \ref NaN if no primal solution is found.
  1934     ///- The (finite) objective value if an optimal solution is found.
  1932     ///- The (finite) objective value if an optimal solution is found.
  1935     Value primal() const { return _getPrimalValue()+obj_const_comp;}
  1933     Value primal() const { return _getPrimalValue()+obj_const_comp;}
  1936     ///@}
  1934     ///@}
  1937 
  1935 
  1938     LpSolver* newSolver() {return _newSolver();}
       
  1939     LpSolver* cloneSolver() {return _cloneSolver();}
       
  1940 
       
  1941   protected:
  1936   protected:
  1942 
  1937 
  1943     virtual LpSolver* _newSolver() const = 0;
       
  1944     virtual LpSolver* _cloneSolver() const = 0;
       
  1945   };
  1938   };
  1946 
  1939 
  1947 
  1940 
  1948   /// \ingroup lp_group
  1941   /// \ingroup lp_group
  1949   ///
  1942   ///
  1973       ///
  1966       ///
  1974       ///The Mip or at least the relaxed problem is unbounded
  1967       ///The Mip or at least the relaxed problem is unbounded
  1975       UNBOUNDED = 4
  1968       UNBOUNDED = 4
  1976     };
  1969     };
  1977 
  1970 
       
  1971     ///Allocate a new MIP problem instance
       
  1972     virtual MipSolver* newSolver() const = 0;
       
  1973     ///Make a copy of the MIP problem
       
  1974     virtual MipSolver* cloneSolver() const = 0;
       
  1975 
  1978     ///\name Solve the MIP
  1976     ///\name Solve the MIP
  1979 
  1977 
  1980     ///@{
  1978     ///@{
  1981 
  1979 
  1982     /// Solve the MIP problem at hand
  1980     /// Solve the MIP problem at hand
  2060     virtual void _setColType(int col, ColTypes col_type) = 0;
  2058     virtual void _setColType(int col, ColTypes col_type) = 0;
  2061     virtual ProblemType _getType() const = 0;
  2059     virtual ProblemType _getType() const = 0;
  2062     virtual Value _getSol(int i) const = 0;
  2060     virtual Value _getSol(int i) const = 0;
  2063     virtual Value _getSolValue() const = 0;
  2061     virtual Value _getSolValue() const = 0;
  2064 
  2062 
  2065   public:
       
  2066 
       
  2067     MipSolver* newSolver() {return _newSolver();}
       
  2068     MipSolver* cloneSolver() {return _cloneSolver();}
       
  2069 
       
  2070   protected:
       
  2071 
       
  2072     virtual MipSolver* _newSolver() const = 0;
       
  2073     virtual MipSolver* _cloneSolver() const = 0;
       
  2074   };
  2063   };
  2075 
  2064 
  2076 
  2065 
  2077 
  2066 
  2078 } //namespace lemon
  2067 } //namespace lemon