00001 // Copyright (C) 2000, International Business Machines 00002 // Corporation and others. All Rights Reserved. 00003 #ifndef _BCP_SOLUTION_H 00004 #define _BCP_SOLUTION_H 00005 00006 #include "BCP_vector.hpp" 00007 #include "BCP_var.hpp" 00008 00009 // This file is fully docified. 00010 00014 class BCP_solution { 00015 public: 00017 virtual ~BCP_solution() {} 00019 virtual double objective_value() const = 0; 00020 }; 00021 00022 //############################################################################# 00023 00033 class BCP_solution_generic : public BCP_solution { 00034 public: 00038 double _objective; 00041 bool _delete_vars; 00043 BCP_vec<BCP_var*> _vars; 00045 BCP_vec<double> _values; 00048 public: 00050 BCP_solution_generic(bool delvars = true) : 00051 _objective(0), _delete_vars(delvars), _vars(), _values() {} 00055 virtual ~BCP_solution_generic() { 00056 if (_delete_vars) 00057 purge_ptr_vector(_vars); 00058 } 00059 00061 inline virtual double objective_value() const { return _objective; } 00062 00064 inline void set_objective_value(double v) { _objective = v; } 00065 00067 void display() const; 00068 00071 void add_entry(BCP_var* var, double value) { 00072 _vars.push_back(var); 00073 _values.push_back(value); 00074 _objective += value * var->obj(); 00075 } 00076 }; 00077 00078 #endif