idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
NodeScoreFunction.h
1//
2// Created by henri on 17.10.23.
3//
4
5#ifndef IDOL_NODESCOREFUNCTION_H
6#define IDOL_NODESCOREFUNCTION_H
7
8#include <algorithm>
9
10namespace idol {
11 class NodeScoreFunction;
12
13 namespace NodeScoreFunctions {
14 class Product;
15 class Linear;
16 }
17
18}
19
21public:
22 virtual ~NodeScoreFunction() = default;
23
24 virtual double operator()(double t_left, double t_right) = 0;
25
26 [[nodiscard]] virtual NodeScoreFunction* clone() const = 0;
27};
28
30 double m_parameter = 1./16.;
31public:
32 Linear() = default;
33
34 explicit Linear(double t_parameter) : m_parameter(t_parameter) {}
35
36 Linear(const Linear&) = default;
37 Linear(Linear&&) = default;
38
39 Linear& operator=(const Linear&) = default;
40 Linear& operator=(Linear&&) = default;
41
42 double operator()(double t_left, double t_right) override {
43 return (1 - m_parameter) * std::min(t_left, t_right) + m_parameter * std::max(t_left, t_right);
44 }
45
46 [[nodiscard]] Linear *clone() const override {
47 return new Linear(*this);
48 }
49};
50
52 double m_parameter = 10e-6;
53public:
54 Product() = default;
55
56 explicit Product(double t_parameter) : m_parameter(t_parameter) {}
57
58 Product(const Product&) = default;
59 Product(Product&&) = default;
60
61 Product& operator=(const Product&) = default;
62 Product& operator=(Product&&) = default;
63
64 double operator()(double t_left, double t_right) override {
65 return std::min(m_parameter, t_left) * std::min(m_parameter, t_right);
66 }
67
68 [[nodiscard]] Product *clone() const override {
69 return new Product(*this);
70 }
71};
72
73#endif //IDOL_NODESCOREFUNCTION_H