Skip to content

Commit

Permalink
Merge branch 'release/2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
richoux committed Jul 8, 2022
2 parents a915cec + db91fa0 commit 8cc075e
Show file tree
Hide file tree
Showing 25 changed files with 610 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Update clang
run: |
brew update
brew upgrade llvm
#brew upgrade llvm
export CXX="/usr/local/opt/llvm/bin/clang++"
- name: Install gtest manually
Expand Down
55 changes: 20 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,21 @@ set(libHeadersList
"${CMAKE_CURRENT_SOURCE_DIR}/include/solver.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/options.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/print.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/macros.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/variable_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/variable_candidates_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/value_heuristic.hpp")
"${CMAKE_CURRENT_SOURCE_DIR}/include/macros.hpp")

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/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/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/antidote_search_value_heuristic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/algorithms/culprit_search_error_projection_heuristic.hpp")

set(libHeadersGlobalConstraintsList
"${CMAKE_CURRENT_SOURCE_DIR}/include/global_constraints/all_different.hpp"
Expand All @@ -119,8 +122,7 @@ set(libExternalHeadersList
# add the targets
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)

# add the library
add_library(ghost SHARED
set(toAddInLibs
src/variable.cpp
src/constraint.cpp
src/objective.cpp
Expand All @@ -132,42 +134,25 @@ add_library(ghost SHARED
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/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/global_constraints/all_different.cpp
src/global_constraints/fix_value.cpp
src/global_constraints/linear_equation.cpp
"${libHeadersList}"
"${libHeadersAlgorithmsList}"
"${libHeadersGlobalConstraintsList}")
src/global_constraints/linear_equation.cpp)

# add the library
add_library(ghost SHARED
"${toAddInLibs}")

add_library(ghost_static STATIC
src/variable.cpp
src/constraint.cpp
src/objective.cpp
src/auxiliary_data.cpp
src/model.cpp
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/antidote_search_variable_heuristic.cpp
src/algorithms/antidote_search_variable_candidates_heuristic.cpp
src/algorithms/antidote_search_value_heuristic.cpp
src/global_constraints/all_different.cpp
src/global_constraints/fix_value.cpp
src/global_constraints/linear_equation.cpp
"${libHeadersList}"
"${libHeadersAlgorithmsList}"
"${libHeadersGlobalConstraintsList}")
"${toAddInLibs}")

target_include_directories(ghost PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/thirdparty/>
$<INSTALL_INTERFACE:include/ghost/thirdparty>
)
$<INSTALL_INTERFACE:include/ghost/thirdparty>)

# add the install targets
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32bits
Expand All @@ -187,8 +172,8 @@ 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 "3")
set (CPACK_PACKAGE_VERSION_PATCH "1")
set (CPACK_PACKAGE_VERSION_MINOR "4")
set (CPACK_PACKAGE_VERSION_PATCH "0")
set (CPACK_PACKAGE_CONTACT "[email protected]")
set (CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
include (CPack)
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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

## [2.4.0] - 2022-07-08
- Error projection is now implemented following the Strategy pattern.

## [2.3.1] - 2022-06-29
- Fix an error in the AllDifferent global constraint.
- Add a constructor taking an argument std::vector<ghost::Variable> for each global constraint.
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)

[![2.3.1](https://img.shields.io/badge/stable-2.3.1-brightgreen.svg)](https://github.com/richoux/GHOST/releases/tag/2.3.1)
[![2.3.x](https://img.shields.io/badge/latest-2.3.x-f57f17.svg)](https://github.com/richoux/GHOST/tree/develop)
[![2.4.0](https://img.shields.io/badge/stable-2.4.0-brightgreen.svg)](https://github.com/richoux/GHOST/releases/tag/2.4.0)
[![2.4.x](https://img.shields.io/badge/latest-2.4.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
55 changes: 55 additions & 0 deletions include/algorithms/adaptive_search_error_projection_heuristic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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/EFSP/EFOP.
*
* First developped 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-2022 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 "error_projection_heuristic.hpp"

namespace ghost
{
namespace algorithms
{
class AdaptiveSearchErrorProjection : public ErrorProjection
{
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 update_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
std::shared_ptr<Constraint> constraint,
double delta ) override;
};
}
}
2 changes: 1 addition & 1 deletion include/algorithms/adaptive_search_value_heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <vector>

#include "../value_heuristic.hpp"
#include "value_heuristic.hpp"

namespace ghost
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <vector>

#include "../variable_candidates_heuristic.hpp"
#include "variable_candidates_heuristic.hpp"

namespace ghost
{
Expand Down
2 changes: 1 addition & 1 deletion include/algorithms/adaptive_search_variable_heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <vector>

#include "../variable_heuristic.hpp"
#include "variable_heuristic.hpp"

namespace ghost
{
Expand Down
2 changes: 1 addition & 1 deletion include/algorithms/antidote_search_value_heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <vector>

#include "../value_heuristic.hpp"
#include "value_heuristic.hpp"

namespace ghost
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <vector>

#include "../variable_candidates_heuristic.hpp"
#include "variable_candidates_heuristic.hpp"

namespace ghost
{
Expand Down
2 changes: 1 addition & 1 deletion include/algorithms/antidote_search_variable_heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <vector>

#include "../variable_heuristic.hpp"
#include "variable_heuristic.hpp"

namespace ghost
{
Expand Down
63 changes: 63 additions & 0 deletions include/algorithms/culprit_search_error_projection_heuristic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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/EFSP/EFOP.
*
* First developped 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-2022 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 "error_projection_heuristic.hpp"

namespace ghost
{
namespace algorithms
{
class CulpritSearchErrorProjection : public ErrorProjection
{
std::vector<std::vector<double>> _error_variables_by_constraints;

void compute_variable_errors_on_constraint( const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
std::shared_ptr<Constraint> constraint );

public:
CulpritSearchErrorProjection();

void initialize_data_structures() 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 update_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
std::shared_ptr<Constraint> constraint,
double delta ) override;
};
}
}
72 changes: 72 additions & 0 deletions include/algorithms/error_projection_heuristic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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/EFSP/EFOP.
*
* First developped 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-2022 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 <memory>

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

namespace ghost
{
namespace algorithms
{
class ErrorProjection
{
protected:
std::string name;
int number_variables;
int number_constraints;

public:
ErrorProjection( std::string&& name )
: name( std::move( 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() {};

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;

virtual void update_variable_errors( std::vector<double>& error_variables,
const std::vector<Variable>& variables,
const std::vector<std::vector<int>>& matrix_var_ctr,
std::shared_ptr<Constraint> constraint,
double delta ) = 0;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#include <vector>
#include <map>

#include "search_unit_data.hpp"
// #include "macros.hpp"
#include "thirdparty/randutils.hpp"
#include "../search_unit_data.hpp"
// #include "../macros.hpp"
#include "../thirdparty/randutils.hpp"

namespace ghost
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

#include <vector>

#include "search_unit_data.hpp"
// #include "macros.hpp"
#include "../search_unit_data.hpp"
// #include "../macros.hpp"

namespace ghost
{
Expand Down
Loading

0 comments on commit 8cc075e

Please sign in to comment.