Bcp 1.4.4
Loading...
Searching...
No Matches
BCP_solution.hpp
Go to the documentation of this file.
1// Copyright (C) 2000, International Business Machines
2// Corporation and others. All Rights Reserved.
3#ifndef _BCP_SOLUTION_H
4#define _BCP_SOLUTION_H
5
6#include "BCP_vector.hpp"
7#include "BCP_var.hpp"
8
9// This file is fully docified.
10
15public:
17 virtual ~BCP_solution() {}
19 virtual double objective_value() const = 0;
20};
21
22//#############################################################################
23
34public:
38 double _objective;
48public:
50 BCP_solution_generic(bool delvars = true) :
51 _objective(0), _delete_vars(delvars), _vars(), _values() {}
59
61 inline virtual double objective_value() const { return _objective; }
62
64 inline void set_objective_value(double v) { _objective = v; }
65
67 void display() const;
68
71 void add_entry(BCP_var* var, double value) {
72 _vars.push_back(var);
73 _values.push_back(value);
74 _objective += value * var->obj();
75 }
76};
77
78#endif
void purge_ptr_vector(BCP_vec< T * > &pvec, typename BCP_vec< T * >::iterator first, typename BCP_vec< T * >::iterator last)
This function purges the entries [first,last) from the vector of pointers pvec.
This class holds a MIP feasible primal solution.
virtual ~BCP_solution_generic()
The destructor deletes the data members.
BCP_vec< BCP_var * > _vars
Vector of variables that are at nonzero level in the solution.
virtual double objective_value() const
Return the objective value of the solution.
BCP_solution_generic(bool delvars=true)
The default constructor creates a solution with zero objective value.
void add_entry(BCP_var *var, double value)
Append a variable and the corresponding value to the end of the appropriate vectors.
void display() const
Display the solution.
void set_objective_value(double v)
Set the objective value of the solution.
bool _delete_vars
An indicator to show whether the pointers in _vars should be deleted upon destruction or not.
BCP_vec< double > _values
Values of these variables in the solution.
double _objective
The objective value of the solution.
This is the abstract base class for a solution to a Mixed Integer Programming problem.
virtual ~BCP_solution()
The virtual destructor ensures that the correct destructor is invoked.
virtual double objective_value() const =0
The method returning the objective value of the solution.
Abstract base class that defines members common to all types of variables.
Definition BCP_var.hpp:28
double obj() const
Return the objective coefficient.
Definition BCP_var.hpp:87
The class BCP_vec serves the same purpose as the vector class in the standard template library.
void push_back(const_reference x)
Append x to the end of the vector.