MatCBSolver.hxx

Go to the documentation of this file.
00001 
00002 
00003 #ifndef CONICBUNDLE_MATCBSOLVER_HXX
00004 #define CONICBUNDLE_MATCBSOLVER_HXX
00005 
00014 #include "CBSolver.hxx"
00015 #include "matrix.hxx"
00016 
00017 //------------------------------------------------------------
00018 
00019 
00020 namespace ConicBundle {
00021 
00108 
00131   class PrimalMatrix:public PrimalData, public CH_Matrix_Classes::Matrix
00132   {
00133 
00134   public:
00136     PrimalMatrix(){}
00143     PrimalMatrix(CH_Matrix_Classes::Integer nr,CH_Matrix_Classes::Integer nc):Matrix(nr,nc)   {}
00145     PrimalMatrix(CH_Matrix_Classes::Integer r,CH_Matrix_Classes::Integer c,CH_Matrix_Classes::Real d)    :Matrix(r,c,d) {}
00147     PrimalMatrix(const PrimalMatrix& pm):PrimalData(),Matrix(pm)    {}  
00149     PrimalMatrix(const CH_Matrix_Classes::Matrix& pm):Matrix(pm)    {} 
00151     PrimalMatrix& operator=(const CH_Matrix_Classes::Matrix& pd)  
00152     { Matrix::operator=(pd); return *this; }
00153     
00155     PrimalData* clone_primal_data(){return new PrimalMatrix(*this);}
00156 
00158     int assign_primal_data(const PrimalData& it)
00159     {
00160       const PrimalMatrix* pd=dynamic_cast<const PrimalMatrix*>(&it);
00161       assert(pd!=0);
00162       *this = *pd;
00163       return 0;
00164     }
00165 
00167     int aggregate_primal_data(double myfactor,double itsfactor,const PrimalData& it)
00168     {
00169       const PrimalMatrix* pd=dynamic_cast<const PrimalMatrix*>(&it);
00170       if (pd!=0) {
00171         CH_Matrix_Classes::xbpeya(*this,*pd,itsfactor,myfactor);
00172         return 0;
00173       }
00174       return 1;
00175     }
00176   };
00177 
00178 
00210   class MatrixFunctionOracle: public FunctionObject 
00211   {
00212   public:
00213         
00316     virtual
00317     int
00318     evaluate
00319     (
00320      const  CH_Matrix_Classes::Matrix&          current_point,
00321      double relprec,
00322      double&                 objective_value,
00323      CH_Matrix_Classes::Matrix&  cut_values,   
00324      CH_Matrix_Classes::Matrix&  eps_subgradients,
00325      std::vector<PrimalData*>&    primal_data,
00326      PrimalExtender*& primal_extender
00327      )
00328       = 0;
00329 
00371     virtual
00372     int
00373     subgradient_extension
00374     (
00375      const PrimalData* /* generating_primal */,
00376      const CH_Matrix_Classes::Indexmatrix& /* variable_indices */, 
00377      CH_Matrix_Classes::Matrix& /* new_subgradient_values */)
00378     {return 1;}
00379 
00380        
00381   };
00382 
00383   
00384   class MatrixBSolver;
00385 
00403   class MatrixCBSolver
00404   {
00405   private:              
00406     MatrixBSolver* solver;                       
00407     MatrixCBSolver ( const CBSolver& );           
00408     MatrixCBSolver& operator= ( const CBSolver& );
00409   public:    
00410     
00415     MatrixCBSolver(bool no_bundle=false);
00417     ~MatrixCBSolver();
00418     
00419     //------------------------------------------------------------
00422        
00426     void clear();
00427 
00430     void set_defaults();
00431 
00473     int init_problem(int dim, 
00474                      const CH_Matrix_Classes::Matrix* lbounds=0,
00475                      const CH_Matrix_Classes::Matrix* ubounds=0,                     
00476                      const CH_Matrix_Classes::Matrix* costs=0);
00477     
00478 
00492     int
00493     add_function
00494     ( FunctionObject& function );
00495     
00507     int set_lower_bound(int i, double lb);
00508 
00520     int set_upper_bound(int i, double ub); 
00521 
00522 
00560     int append_variables(int n_append,                   
00561                          const CH_Matrix_Classes::Matrix* lbounds=0,
00562                          const CH_Matrix_Classes::Matrix* ubounds=0,
00563                          const CH_Matrix_Classes::Matrix* costs=0);
00564 
00596     int delete_variables(const CH_Matrix_Classes::Indexmatrix& del_indices,CH_Matrix_Classes::Indexmatrix& map_to_old);
00597 
00625     int reassign_variables(const CH_Matrix_Classes::Indexmatrix& assign_new_from_old);
00626 
00628 
00629     //------------------------------------------------------------
00632     
00680     int 
00681     do_descent_step(int maxsteps=0);
00682     
00683     
00718     int
00719     termination_code() 
00720       const; 
00721     
00729     std::ostream&
00730     print_termination_code(std::ostream& out); 
00731     
00737     double 
00738     get_objval()
00739       const;
00740     
00751     int 
00752     get_center
00753     ( CH_Matrix_Classes::Matrix& center )
00754       const;
00755     
00756     
00759     double 
00760     get_sgnorm()
00761       const; 
00762 
00770     int 
00771     get_subgradient
00772     ( CH_Matrix_Classes::Matrix& subgradient )
00773       const;
00774 
00778     double 
00779     get_cutval()
00780       const;
00781     
00790     double 
00791     get_candidate_value()
00792       const;
00793     
00804     int 
00805     get_candidate
00806     ( CH_Matrix_Classes::Matrix& center )
00807       const;
00808     
00809     
00811     
00812     //------------------------------------------------------------
00815 
00829     int 
00830     set_term_relprec
00831     ( const double term_relprec );
00832     
00841     int
00842     set_new_center_point
00843     ( const CH_Matrix_Classes::Matrix& center_point );
00844 
00845     
00849      int 
00850     get_function_status
00851     ( const FunctionObject& function )
00852       const;
00853 
00861     int 
00862     get_approximate_slacks(CH_Matrix_Classes::Matrix &)
00863       const;
00864     
00878     int
00879     get_approximate_primal
00880     ( const FunctionObject& function,
00881       PrimalData&              primal )
00882       const; 
00883     
00897     int
00898     get_center_primal
00899     ( const FunctionObject& function,
00900       PrimalData&              primal )
00901       const; 
00902 
00903 
00914     int
00915     get_candidate_primal
00916     ( const FunctionObject& function,
00917       PrimalData&              primal )
00918       const; 
00919 
00920 
00946     int 
00947     set_max_bundlesize
00948     (  const FunctionObject& function, int max_bundlesize );
00949 
00967     int 
00968     set_max_new_subgradients
00969     (  const FunctionObject& function, int max_new_subgradients );
00970 
00987     int 
00988     set_bundle_parameters
00989     (  const FunctionObject& function,
00990        const BundleParameters& params );
00991 
01008     int 
01009     get_bundle_parameters
01010     ( const FunctionObject& function, BundleParameters& params )
01011       const;
01012 
01030     int 
01031     get_bundle_values
01032     ( const FunctionObject& function, BundleParameters& params )
01033       const;
01034 
01050     int reinit_function_model
01051     ( const FunctionObject& function );
01052     
01067     int clear_aggregates
01068     ( const FunctionObject& function );
01069     
01070 
01091     int call_primal_extender
01092     (const FunctionObject& function,
01093      PrimalExtender& primal_extender);
01094 
01095 
01099     double 
01100     get_last_weight()
01101       const; 
01102 
01123     int 
01124     set_next_weight
01125     ( const double weight );
01126     
01141     int 
01142     set_min_weight
01143     ( const double min_weight ); 
01144 
01158     int 
01159     set_max_weight
01160     ( const double max_weight );
01161     
01178     int 
01179     adjust_multiplier
01180     ( void );
01181     
01182 
01189     int
01190     set_scaling
01191     ( bool do_scaling );
01192 
01208     int
01209     set_scaling
01210     ( const CH_Matrix_Classes::Matrix& scale );
01211 
01236     void
01237     set_active_bounds_fixing
01238     ( bool allow_fixing );
01239 
01247     void 
01248     clear_fail_counts
01249     (void);
01250     
01264     void 
01265     set_eval_limit
01266     (int eval_limit);
01267 
01281     void 
01282     set_inner_update_limit
01283     (int update_limit);
01284     
01286     
01287     //------------------------------------------------------------
01293     int get_dim() const;
01294 
01297     int get_n_functions() const;
01298 
01301     int get_n_oracle_calls() const;
01302 
01305     int get_n_descent_steps() const;
01306 
01309     int get_n_inner_iterations() const;
01310 
01313     int get_n_inner_updates() const;
01314 
01317     const CH_Matrix_Classes::Matrix& get_lbounds() const;
01318 
01321     const CH_Matrix_Classes::Matrix& get_ubounds() const;
01322     
01331     const CH_Matrix_Classes::Indexmatrix& get_active_bounds_indicator() const;
01332 
01334 
01335     //------------------------------------------------------------
01338 
01396     void 
01397     set_out
01398     (std::ostream* out=0,int print_level=1);
01399 
01401     std::ostream& print_line_summary(std::ostream& out) const;
01402 
01404     
01405   };
01406 
01408 }
01409 
01410 #endif
01411 
01412 
01413 

Generated on Tue May 3 16:52:53 2011 for ConicBundle by  doxygen 1.5.6