Blis 0.94
BlisSolution.h
Go to the documentation of this file.
1/*===========================================================================*
2 * This file is part of the BiCePS Linear Integer Solver (BLIS). *
3 * *
4 * ALPS is distributed under the Eclipse Public License as part of the *
5 * COIN-OR repository (http://www.coin-or.org). *
6 * *
7 * Authors: *
8 * *
9 * Yan Xu, Lehigh University *
10 * Ted Ralphs, Lehigh University *
11 * *
12 * Conceptual Design: *
13 * *
14 * Yan Xu, Lehigh University *
15 * Ted Ralphs, Lehigh University *
16 * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17 * Matthew Saltzman, Clemson University *
18 * *
19 * *
20 * Copyright (C) 2001-2019, Lehigh University, Yan Xu, and Ted Ralphs. *
21 * All Rights Reserved. *
22 *===========================================================================*/
23
24#ifndef BlisSolution_h_
25#define BlisSolution_h_
26
27#include "Alps.h"
28#include "BcpsSolution.h"
29
30//#############################################################################
34//#############################################################################
35
36class BlisSolution : public BcpsSolution {
37
38 protected:
39
40 public:
41
44 :
46 {}
47
49 BlisSolution(int s, const double *values, double objValue)
50 :
51 BcpsSolution(s, values, objValue)
52 {}
53
55 virtual ~BlisSolution() { }
56
59 virtual void print(std::ostream& os) const {
60 double nearInt = 0.0;
61 for (int j = 0; j < size_; ++j) {
62 if (values_[j] > 1.0e-15 || values_[j] < -1.0e-15) {
63 nearInt = floor(values_[j] + 0.5);
64 if (ALPS_FABS(nearInt - values_[j]) < 1.0e-6) {
65 os << "x[" << j << "] = " << nearInt << std::endl;
66 }
67 else {
68 os << "x[" << j << "] = " << values_[j] << std::endl;
69 }
70 }
71 }
72 }
73
76 // BlisIpSolution* testIntegrality(const double etol = 1e-5) const;
77
80 virtual AlpsEncoded* encode() const {
82 encodeBcps(encoded);
83 // Nothing to do for Blis part.
84 return encoded;
85 }
86
88 virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
89 BlisSolution * sol = new BlisSolution();
90 sol->decodeBcps(encoded);
91 return sol;
92 }
93
94};
95
96//#############################################################################
97//#############################################################################
98
99#endif
#define ALPS_FABS(x)
AlpsKnowledgeTypeSolution
virtual AlpsEncoded * encode() const
AlpsReturnStatus decodeBcps(AlpsEncoded &encoded)
double * values_
AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const
This class contains the solutions generated by the LP solver (either primal or dual.
Definition: BlisSolution.h:36
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
The method that decodes the solution from a encoded object.
Definition: BlisSolution.h:88
virtual AlpsEncoded * encode() const
The method that encodes the solution into a encoded object.
Definition: BlisSolution.h:80
virtual void print(std::ostream &os) const
Print out the solution.
Definition: BlisSolution.h:59
virtual ~BlisSolution()
Destructor.
Definition: BlisSolution.h:55
BlisSolution()
Default constructor.
Definition: BlisSolution.h:43
BlisSolution(int s, const double *values, double objValue)
Useful constructor.
Definition: BlisSolution.h:49