GHOST
auxiliary_data.hpp
Go to the documentation of this file.
1 /*
2  * GHOST (General meta-Heuristic Optimization Solving Tool) is a C++ framework
3  * designed to help developers to model and implement optimization problem
4  * solving. It contains a meta-heuristic solver aiming to solve any kind of
5  * combinatorial and optimization real-time problems represented by a CSP/COP/EF-CSP/EF-COP.
6  *
7  * First developed to solve game-related optimization problems, GHOST can be used for
8  * any kind of applications where solving combinatorial and optimization problems. In
9  * particular, it had been designed to be able to solve not-too-complex problem instances
10  * within some milliseconds, making it very suitable for highly reactive or embedded systems.
11  * Please visit https://github.com/richoux/GHOST for further information.
12  *
13  * Copyright (C) 2014-2023 Florian Richoux
14  *
15  * This file is part of GHOST.
16  * GHOST is free software: you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License as published
18  * by the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20 
21  * GHOST is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25 
26  * You should have received a copy of the GNU General Public License
27  * along with GHOST. If not, see http://www.gnu.org/licenses/.
28  */
29 
30 #pragma once
31 
32 #include <vector>
33 #include <map>
34 
35 #include "variable.hpp"
36 
37 namespace ghost
38 {
39  /*******************/
41  /*******************/
42 
56  {
57  friend class SearchUnit;
58  friend class ModelBuilder;
59 
60  std::vector<Variable*> _variables;
61  std::vector<int> _variables_index; // To know where are the constraint's variables in the global variable vector
62  std::map<int,int> _variables_position; // To know where are global variables in the constraint's variables vector
63 
64  void update();
65  void update( int index, int new_value );
66 
67  protected:
80  virtual void required_update( const std::vector<Variable*>& variables, int index, int new_value ) = 0;
81 
82  public:
85 
92  AuxiliaryData( const std::vector<int>& variables_index );
93 
98  AuxiliaryData( const std::vector<Variable>& variables );
99 
101  AuxiliaryData( const AuxiliaryData& other ) = default;
103  AuxiliaryData( AuxiliaryData&& other ) = default;
104 
106  AuxiliaryData& operator=( const AuxiliaryData& other ) = delete;
108  AuxiliaryData& operator=( AuxiliaryData&& other ) = delete;
109 
111  virtual ~AuxiliaryData() = default;
112  };
113 
114  /***********************/
116  /***********************/
117  // NullAuxiliaryData is used when no auxiliary data are necessary in the model.
118  class NullAuxiliaryData : public AuxiliaryData
119  {
120  public:
121  NullAuxiliaryData()
122  : AuxiliaryData()
123  { }
124 
125  void required_update( const std::vector<Variable*>& variables, int index, int new_value ) override { }
126  };
127 }
Definition: auxiliary_data.hpp:56
AuxiliaryData(const std::vector< int > &variables_index)
virtual ~AuxiliaryData()=default
Default virtual destructor.
friend class SearchUnit
Definition: auxiliary_data.hpp:57
AuxiliaryData(AuxiliaryData &&other)=default
Default move contructor.
AuxiliaryData()
Constructor instanciating an empty vector of variable IDs.
AuxiliaryData & operator=(const AuxiliaryData &other)=delete
Copy assignment operator disabled.
AuxiliaryData & operator=(AuxiliaryData &&other)=delete
Move assignment operator disabled.
AuxiliaryData(const AuxiliaryData &other)=default
Default copy contructor.
virtual void required_update(const std::vector< Variable * > &variables, int index, int new_value)=0
AuxiliaryData(const std::vector< Variable > &variables)
Definition: model_builder.hpp:63
Definition: auxiliary_data.hpp:38