Blis 0.95.0
Loading...
Searching...
No Matches
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-2023, 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#include "BlisConfig.h"
30
31//#############################################################################
35//#############################################################################
36
37class BLISLIB_EXPORT BlisSolution : public BcpsSolution {
38
39 protected:
40
41 public:
42
45 :
46 BcpsSolution()
47 {}
48
50 BlisSolution(int s, const double *values, double objValue)
51 :
52 BcpsSolution(s, values, objValue)
53 {}
54
56 virtual ~BlisSolution() { }
57
60 virtual void print(std::ostream& os) const {
61 double nearInt = 0.0;
62 for (int j = 0; j < size_; ++j) {
63 if (values_[j] > 1.0e-15 || values_[j] < -1.0e-15) {
64 nearInt = floor(values_[j] + 0.5);
65 if (ALPS_FABS(nearInt - values_[j]) < 1.0e-6) {
66 os << "x[" << j << "] = " << nearInt << std::endl;
67 }
68 else {
69 os << "x[" << j << "] = " << values_[j] << std::endl;
70 }
71 }
72 }
73 }
74
77 // BlisIpSolution* testIntegrality(const double etol = 1e-5) const;
78
79 using AlpsKnowledge::encode ;
81 virtual AlpsEncoded* encode() const {
82 AlpsEncoded* encoded = new AlpsEncoded(AlpsKnowledgeTypeSolution);
83 encodeBcps(encoded);
84 // Nothing to do for Blis part.
85 return encoded;
86 }
87
89 virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
90 BlisSolution * sol = new BlisSolution();
91 sol->decodeBcps(encoded);
92 return sol;
93 }
94
95};
96
97//#############################################################################
98//#############################################################################
99
100#endif
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
The method that decodes the solution from a encoded object.
virtual AlpsEncoded * encode() const
The method that encodes the solution into a encoded object.
virtual void print(std::ostream &os) const
Print out the solution.
virtual ~BlisSolution()
Destructor.
BlisSolution()
Default constructor.
BlisSolution(int s, const double *values, double objValue)
Useful constructor.
#define BLISLIB_EXPORT
Definition config.h:5