00001 /************************************************************************* 00002 * 00003 * The Contents of this file are made available subject to 00004 * the terms of GNU Lesser General Public License Version 2.1. 00005 * 00006 * 00007 * GNU Lesser General Public License Version 2.1 00008 * ============================================= 00009 * Copyright 2005 by Kohei Yoshida. 00010 * 1039 Kingsway Dr., Apex, NC 27502, USA 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License version 2.1, as published by the Free Software Foundation. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this library; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00024 * MA 02111-1307 USA 00025 * 00026 ************************************************************************/ 00027 00028 00029 #ifndef _SCSOLVER_LPBUILDER_HXX_ 00030 #define _SCSOLVER_LPBUILDER_HXX_ 00031 00032 #include "type.hxx" 00033 #include <memory> 00034 #include <vector> 00035 #include <com/sun/star/table/CellAddress.hpp> 00036 00037 00038 namespace scsolver { 00039 00040 namespace numeric { namespace lp { 00041 class Model; 00042 }} 00043 00044 class LpModelBuilderImpl; 00045 00046 00050 class ConstraintAddress 00051 { 00052 public: 00053 ConstraintAddress(); 00054 ConstraintAddress( const ConstraintAddress& ); 00055 ~ConstraintAddress() throw(); 00056 00057 bool equals( const ConstraintAddress& ) const; 00058 bool operator==( const ConstraintAddress & ) const; 00059 00060 ::com::sun::star::table::CellAddress getLeftCellAddr() const; 00061 void setLeftCellAddr( const ::com::sun::star::table::CellAddress& addr ); 00062 00063 ::com::sun::star::table::CellAddress getRightCellAddr() const; 00064 void setRightCellAddr( const ::com::sun::star::table::CellAddress& addr ); 00065 double getLeftCellValue() const; 00066 double getRightCellValue() const; 00067 void setLeftCellValue( double value ); 00068 void setRightCellValue( double value ); 00069 bool isLeftCellNumeric() const; 00070 bool isRightCellNumeric() const; 00071 00072 numeric::EqualityType getEquality() const; 00073 void setEquality( numeric::EqualityType eq ); 00074 00075 private: 00076 00077 ::com::sun::star::table::CellAddress Left; 00078 ::com::sun::star::table::CellAddress Right; 00079 numeric::EqualityType Equal; 00080 00081 bool m_bIsLHSNumber:1; 00082 bool m_bIsRHSNumber:1; 00083 double m_fLHSValue; 00084 double m_fRHSValue; 00085 }; 00086 00090 class LpModelBuilder 00091 { 00092 public: 00093 LpModelBuilder(); 00094 ~LpModelBuilder(); 00095 00096 numeric::lp::Model getModel(); 00097 00098 // Optimization objective 00099 numeric::GoalType getGoal() const; 00100 void setGoal( numeric::GoalType ); 00101 00102 // Objective Formula 00103 const ::com::sun::star::table::CellAddress getObjectiveFormulaAddress() const; 00104 void setObjectiveFormulaAddress( const ::com::sun::star::table::CellAddress& ); 00105 00106 // Decision Variables 00107 void setDecisionVarAddress( const ::com::sun::star::table::CellAddress& ); 00108 std::vector< ::com::sun::star::table::CellAddress > getAllDecisionVarAddresses() const; 00109 void clearDecisionVarAddresses(); 00110 00111 // Cost Vector 00112 double getCostVector( const ::com::sun::star::table::CellAddress& ); 00113 void setCostVector( const ::com::sun::star::table::CellAddress&, double ); 00114 00115 // Constraints 00116 void clearConstraintAddresses(); 00117 void setConstraintAddress( const ConstraintAddress& ); 00118 std::vector< ConstraintAddress > getAllConstraintAddresses() const; 00119 void setConstraintMatrixSize( size_t, size_t ); 00120 void setConstraintCoefficient( const ::com::sun::star::table::CellAddress&, 00121 const ConstraintAddress&, double, double ); 00122 00123 // Temporary formula strings 00124 const rtl::OUString getTempCellFormula( const ::com::sun::star::table::CellAddress& ) const; 00125 void setTempCellFormula( const ::com::sun::star::table::CellAddress&, 00126 const rtl::OUString& ); 00127 00128 private: 00129 00130 std::auto_ptr<LpModelBuilderImpl> m_pImpl; 00131 }; 00132 00133 00134 00135 } 00136 00137 #endif
1.5.3