Skip to content

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
richoux committed Mar 11, 2024
2 parents 03f7eab + 8ea77f8 commit a4e66d7
Show file tree
Hide file tree
Showing 69 changed files with 750 additions and 276 deletions.
26 changes: 16 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,18 @@ set(libHeadersAlgorithmsList
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/variable_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/variable_candidates_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/value_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/error_projection_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/adaptive_search_variable_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/error_projection_algorithm.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/adaptive_search_variable_candidates_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/adaptive_search_value_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/adaptive_search_error_projection_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/adaptive_search_error_projection_algorithm.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/antidote_search_variable_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/antidote_search_variable_candidates_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/antidote_search_value_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/culprit_search_error_projection_heuristic.hpp")
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/culprit_search_error_projection_algorithm.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/uniform_variable_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/all_free_variable_candidates_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/random_walk_value_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/null_error_projection_algorithm.hpp")

set(libHeadersGlobalConstraintsList
"${CMAKE_CURRENT_SOURCE_DIR}/include/global_constraints/all_different.hpp"
Expand Down Expand Up @@ -138,14 +141,17 @@ set(toAddInLibs
src/model_builder.cpp
src/options.cpp
src/print.cpp
src/algorithms/adaptive_search_variable_heuristic.cpp
src/algorithms/adaptive_search_variable_candidates_heuristic.cpp
src/algorithms/adaptive_search_value_heuristic.cpp
src/algorithms/adaptive_search_error_projection_heuristic.cpp
src/algorithms/adaptive_search_error_projection_algorithm.cpp
src/algorithms/antidote_search_variable_heuristic.cpp
src/algorithms/antidote_search_variable_candidates_heuristic.cpp
src/algorithms/antidote_search_value_heuristic.cpp
src/algorithms/culprit_search_error_projection_heuristic.cpp
src/algorithms/culprit_search_error_projection_algorithm.cpp
src/algorithms/uniform_variable_heuristic.cpp
src/algorithms/all_free_variable_candidates_heuristic.cpp
src/algorithms/random_walk_value_heuristic.cpp
src/algorithms/null_error_projection_algorithm.cpp
src/global_constraints/all_different.cpp
src/global_constraints/all_equal.cpp
src/global_constraints/fix_value.cpp
Expand Down Expand Up @@ -199,9 +205,9 @@ endif()
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_NAME "GHOST")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR "2")
set (CPACK_PACKAGE_VERSION_MINOR "8")
set (CPACK_PACKAGE_VERSION_PATCH "2")
set (CPACK_PACKAGE_VERSION_MAJOR "3")
set (CPACK_PACKAGE_VERSION_MINOR "1")
set (CPACK_PACKAGE_VERSION_PATCH "0")
set (CPACK_PACKAGE_CONTACT "[email protected]")
set (CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
include (CPack)
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file, since GHOST 2.0.0.

## [3.1.0] - 2024-03-11
- Add Random Walk and Hill Climbing as search algorithms, for landscape analysis.
- Minor changes in the global solver algorithm, such as removing the probability to force tabu-marking a variable.

## [3.0.2] - 2023-09-26
- Fix a mistake with maximization objectives in the complete solver, and a bug that happened with the compiler Clang.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![](https://github.com/richoux/GHOST/wiki/images/GHOST_banner.png)

[![3.0.2](https://img.shields.io/badge/stable-3.0.2-brightgreen.svg)](https://github.com/richoux/GHOST/releases/tag/3.0.2)
[![3.0.x](https://img.shields.io/badge/latest-3.0.x-f57f17.svg)](https://github.com/richoux/GHOST/tree/develop)
[![3.1.0](https://img.shields.io/badge/stable-3.1.0-brightgreen.svg)](https://github.com/richoux/GHOST/releases/tag/3.1.0)
[![3.1.x](https://img.shields.io/badge/latest-3.1.x-f57f17.svg)](https://github.com/richoux/GHOST/tree/develop)
[![Actions Status](https://github.com/richoux/GHOST/workflows/Linux/badge.svg)](https://github.com/richoux/GHOST/actions)
[![Actions Status](https://github.com/richoux/GHOST/workflows/MacOS/badge.svg)](https://github.com/richoux/GHOST/actions)
[![Actions Status](https://github.com/richoux/GHOST/workflows/Windows/badge.svg)](https://github.com/richoux/GHOST/actions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand All @@ -29,7 +29,7 @@

#pragma once

#include "error_projection_heuristic.hpp"
#include "error_projection_algorithm.hpp"

namespace ghost
{
Expand All @@ -40,15 +40,13 @@ namespace ghost
public:
AdaptiveSearchErrorProjection();

void compute_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
const std::vector<std::shared_ptr<Constraint>>& constraints ) override;
void compute_variable_errors( const std::vector<Variable>& variables,
const std::vector<std::shared_ptr<Constraint>>& constraints,
SearchUnitData& data ) override;

void update_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
void update_variable_errors( const std::vector<Variable>& variables,
std::shared_ptr<Constraint> constraint,
SearchUnitData& data,
double delta ) override;
};
}
Expand Down
14 changes: 7 additions & 7 deletions include/algorithms/adaptive_search_value_heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand Down Expand Up @@ -42,12 +42,12 @@ namespace ghost
public:
AdaptiveSearchValueHeuristic();

int select_value_candidates( int variable_to_change,
const SearchUnitData& data,
const Model& model,
const std::map<int, std::vector<double>>& delta_errors,
double& min_conflict,
randutils::mt19937_rng& rng ) const override;
int select_value( int variable_to_change,
const SearchUnitData& data,
const Model& model,
const std::map<int, std::vector<double>>& delta_errors,
double& min_conflict,
randutils::mt19937_rng& rng ) const override;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand Down
48 changes: 48 additions & 0 deletions include/algorithms/all_free_variable_candidates_heuristic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* GHOST (General meta-Heuristic Optimization Solving Tool) is a C++ framework
* designed to help developers to model and implement optimization problem
* solving. It contains a meta-heuristic solver aiming to solve any kind of
* combinatorial and optimization real-time problems represented by a CSP/COP/EF-CSP/EF-COP.
*
* First developed to solve game-related optimization problems, GHOST can be used for
* any kind of applications where solving combinatorial and optimization problems. In
* particular, it had been designed to be able to solve not-too-complex problem instances
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* GHOST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with GHOST. If not, see http://www.gnu.org/licenses/.
*/

#pragma once

#include <vector>

#include "variable_candidates_heuristic.hpp"

namespace ghost
{
namespace algorithms
{
class AllFreeVariableCandidatesHeuristic : public VariableCandidatesHeuristic
{
public:
AllFreeVariableCandidatesHeuristic();

std::vector<double> compute_variable_candidates( const SearchUnitData& data ) const override;
};
}
}
14 changes: 7 additions & 7 deletions include/algorithms/antidote_search_value_heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand Down Expand Up @@ -42,12 +42,12 @@ namespace ghost
public:
AntidoteSearchValueHeuristic();

int select_value_candidates( int variable_to_change,
const SearchUnitData& data,
const Model& model,
const std::map<int, std::vector<double>>& delta_errors,
double& min_conflict,
randutils::mt19937_rng& rng ) const override;
int select_value( int variable_to_change,
const SearchUnitData& data,
const Model& model,
const std::map<int, std::vector<double>>& delta_errors,
double& min_conflict,
randutils::mt19937_rng& rng ) const override;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand Down
4 changes: 2 additions & 2 deletions include/algorithms/antidote_search_variable_heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand Down Expand Up @@ -42,7 +42,7 @@ namespace ghost
public:
AntidoteSearchVariableHeuristic();

int select_variable_candidate( const std::vector<double>& candidates, const SearchUnitData& data, randutils::mt19937_rng& rng ) const override;
int select_variable( const std::vector<double>& candidates, const SearchUnitData& data, randutils::mt19937_rng& rng ) const override;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand All @@ -29,7 +29,7 @@

#pragma once

#include "error_projection_heuristic.hpp"
#include "error_projection_algorithm.hpp"

namespace ghost
{
Expand All @@ -46,17 +46,15 @@ namespace ghost
public:
CulpritSearchErrorProjection();

void initialize_data_structures() override;
void initialize_data_structures( const SearchUnitData& data ) override;

void compute_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
const std::vector<std::shared_ptr<Constraint>>& constraints ) override;
void compute_variable_errors( const std::vector<Variable>& variables,
const std::vector<std::shared_ptr<Constraint>>& constraints,
SearchUnitData& data ) override;

void update_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
void update_variable_errors( const std::vector<Variable>& variables,
std::shared_ptr<Constraint> constraint,
SearchUnitData& data,
double delta ) override;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* within some milliseconds, making it very suitable for highly reactive or embedded systems.
* Please visit https://github.com/richoux/GHOST for further information.
*
* Copyright (C) 2014-2023 Florian Richoux
* Copyright (C) 2014-2024 Florian Richoux
*
* This file is part of GHOST.
* GHOST is free software: you can redistribute it and/or
Expand All @@ -32,43 +32,46 @@
#include <vector>
#include <memory>

#include "../search_unit_data.hpp"
#include "../constraint.hpp"
#include "../variable.hpp"

namespace ghost
{
namespace algorithms
{
/*
* Strategy design pattern to implement error projection algorithm.
*/
class ErrorProjection
{
protected:
// Protected string variable for the heuristic name. Used for debug/trace purposes.
std::string name;
int number_variables;
int number_constraints;

public:
ErrorProjection( std::string&& name )
: name( std::move( name ) )
{ }

//! Default virtual destructor.
// Default virtual destructor.
virtual ~ErrorProjection() = default;

// Inline function returning the algorithm name.
inline std::string get_name() const { return name; }
inline void set_number_variables( int num ) { number_variables = num ; }
inline void set_number_constraints( int num ) { number_constraints = num ; }

virtual void initialize_data_structures() {};
// Can be useful to initialize some data structures before computing error projections.
virtual void initialize_data_structures( const SearchUnitData& data ) {};

virtual void compute_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
const std::vector<std::shared_ptr<Constraint>>& constraints ) = 0;
// Will reset data.error_variables and set the element of this vector to their projected cost
virtual void compute_variable_errors( const std::vector<Variable>& variables,
const std::vector<std::shared_ptr<Constraint>>& constraints,
SearchUnitData& data ) = 0;

virtual void update_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
// Incremental update of data.error_variables
virtual void update_variable_errors( const std::vector<Variable>& variables,
std::shared_ptr<Constraint> constraint,
SearchUnitData& data,
double delta ) = 0;
};
}
Expand Down
Loading

0 comments on commit a4e66d7

Please sign in to comment.