From d2d8145fa9837e3714d139623e83bc308c838916 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sat, 1 Jun 2024 20:16:52 +0200 Subject: [PATCH 01/69] Create local package and add test_package --- .gitignore | 2 + Build.py | 12 +- CMakeLists.txt | 2 +- Setup.py | 71 +++- conanfile.py | 29 +- sh/prepareData_C2HDM.py | 56 ++- sh/prepareData_CxSM.py | 98 ++--- sh/prepareData_N2HDM.py | 76 ++-- sh/prepareData_R2HDM.py | 38 +- test_package/CMakeLists.txt | 7 + test_package/conanfile.py | 29 ++ test_package/src/example.cpp | 5 + tools/ModelGeneration/sympy/General2HDM.py | 393 +++++++++++------- tools/ModelGeneration/sympy/ModelGenerator.py | 377 ++++++++++++----- tools/ModelGeneration/sympy/SM.py | 168 ++++---- 15 files changed, 877 insertions(+), 486 deletions(-) create mode 100644 test_package/CMakeLists.txt create mode 100644 test_package/conanfile.py create mode 100644 test_package/src/example.cpp diff --git a/.gitignore b/.gitignore index f102b91a..571b3146 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ analyze*.py CMakeUserPresets.json __pycache__/* + +test_package/build/ diff --git a/Build.py b/Build.py index c4882ce1..d326b8a4 100644 --- a/Build.py +++ b/Build.py @@ -2,6 +2,7 @@ import subprocess import sys + def get_preset(): preset = "conan-" os = sys.platform @@ -11,7 +12,7 @@ def get_preset(): preset += "linux" elif os == "darwin": preset += "macos" - + preset += "-" preset += Setup.get_arch() @@ -19,19 +20,20 @@ def get_preset(): return preset + def build(preset): - cmd=f"cmake --preset {preset}".split() + cmd = f"cmake --preset {preset}".split() subprocess.check_call(cmd) - cmd=f"cmake --build --preset {preset}".split() + cmd = f"cmake --build --preset {preset}".split() subprocess.check_call(cmd) def main(): Setup.setup_profiles() - Setup.conan_install_all(Setup.BuildMode.release,build_missing=True) + Setup.conan_install_all(Setup.BuildMode.release, build_missing=True) build(get_preset()) + if __name__ == "__main__": main() - \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 96047eef..b5e29405 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") include(LTO) diff --git a/Setup.py b/Setup.py index a9129e57..927beffc 100644 --- a/Setup.py +++ b/Setup.py @@ -32,10 +32,10 @@ def get_compiler(): if sys.platform != "linux" and sys.platform != "darwin": return compiler - if (sys.platform == "linux"): + if sys.platform == "linux": compiler += "-gcc-" - if (sys.platform == "darwin"): + if sys.platform == "darwin": compiler += "-clang-" compiler += get_compiler_version() @@ -65,27 +65,40 @@ def get_profile(os: str, arch: str, build_type: BuildMode): return profile + def set_setting(file, setting, value): for line in fileinput.input([file], inplace=True): if line.strip().startswith(setting): line = setting + "=" + value + "\n" sys.stdout.write(line) + def check_profile(profile): path = os.path.join("profiles", "BSMPT", profile) if not os.path.isfile(path): - conan_home = subprocess.check_output("conan config home".split(), encoding="UTF-8").split("\n")[0] - print(f"Profile does not exist in BSMPT/profiles.\nUsing profile {profile} created from the default profile. Change it accordingly.") + conan_home = subprocess.check_output( + "conan config home".split(), encoding="UTF-8" + ).split("\n")[0] + print( + f"Profile does not exist in BSMPT/profiles.\nUsing profile {profile} created from the default profile. Change it accordingly." + ) if not os.path.isfile(conan_home + "/profiles/default"): cmd = "conan profile detect".split() subprocess.check_output(cmd) - if (sys.platform != "win32"): - cmd = "cp " + conan_home + "/profiles/default profiles/BSMPT/" + str(profile) + if sys.platform != "win32": + cmd = ( + "cp " + conan_home + "/profiles/default profiles/BSMPT/" + str(profile) + ) subprocess.check_call(cmd, shell=True) set_setting(path, "compiler.cppstd", "gnu17") - + else: - cmd = "copy " + conan_home + "\\profiles\\default profiles\\BSMPT\\" + str(profile) + cmd = ( + "copy " + + conan_home + + "\\profiles\\default profiles\\BSMPT\\" + + str(profile) + ) subprocess.check_call(cmd, shell=True) set_setting(path, "compiler.cppstd", "17") @@ -94,13 +107,13 @@ def check_profile(profile): def get_compiler_version(): - if (sys.platform == "linux"): + if sys.platform == "linux": version_response = subprocess.check_output( "gcc --version".split(), encoding="UTF-8" ).partition("\n")[0] semver_string = version_response[version_response.rfind(" ") + 1 :] return semver_string.partition(".")[0] - if (sys.platform == "darwin"): + if sys.platform == "darwin": version_response = subprocess.check_output( "clang --version".split(), encoding="UTF-8" ).partition("\n")[0] @@ -175,6 +188,21 @@ def conan_install_all( ) +def create(): + + config_settings = [ + "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" + ] + + profile = get_profile(sys.platform, get_arch(), BuildMode.release) + cmd = f"conan create . -pr:h BSMPT/{profile} -pr:b BSMPT/{profile}".split() + + for conf in config_settings: + cmd += ["-c", conf] + + subprocess.check_call(cmd) + + class ArgTypeEnum(Enum): @classmethod def argtype(cls, s: str) -> Enum: @@ -216,11 +244,20 @@ def __str__(self): default="", ) - opts = parser.parse_args() - setup_profiles() - conan_install_all( - opts.mode, - opts.options if opts.options is not None else [], - opts.build_missing, - opts.profile, + parser.add_argument( + "-c", "--create", action="store_true", help="create the local conan package" ) + + opts = parser.parse_args() + + if opts.create: + create() + else: + + setup_profiles() + conan_install_all( + opts.mode, + opts.options if opts.options is not None else [], + opts.build_missing, + opts.profile, + ) diff --git a/conanfile.py b/conanfile.py index de5d6969..8f01036a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,7 +1,9 @@ from conan import ConanFile, tools -from conan.tools.cmake import cmake_layout, CMakeToolchain from conan.tools.system.package_manager import Apt from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import load, update_conandata +from conan.tools.scm import Git required_conan_version = ">=2.0.0 <3" @@ -10,6 +12,11 @@ class BSMPT(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps" + name = "bsmpt" + version = "3.0.2" + + exports_sources = "CMakeLists.txt", "src/*", "include/*", "tools/*", "tests/*" , "standalone/*" + options = { "EnableTests": [True, False], # enables the unit tests "UseLibCMAES": [ @@ -82,5 +89,23 @@ def validate(self): if self.settings.os != "Linux" and self.options.EnableCoverage: raise ConanInvalidConfiguration("We depend on lcov for coverage.") - + tools.build.check_min_cppstd(self, "17") + + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + diff --git a/sh/prepareData_C2HDM.py b/sh/prepareData_C2HDM.py index b24f2744..7aeaf773 100755 --- a/sh/prepareData_C2HDM.py +++ b/sh/prepareData_C2HDM.py @@ -7,36 +7,48 @@ import sys ####### The parameters Type, Lambda1 to Lambda4, re_Lambda5, im_Lambda5, tanbeta and re_m12squared should have the label -####### of the corresponding parameter. With Seperator you have to tell which seperator your data file +####### of the corresponding parameter. With Seperator you have to tell which seperator your data file ####### is using (e.g. , \t or space). Your InputFILE will then be saved to OutputFILE. + def convert(InputFile, OutputFile): - print(f'Reading {InputFile}.') - print(f'Output is saved to {OutputFile}.') - - HasIndexCol=False - Separator='\t' - Type='yuktype' - Lambda1='L1' - Lambda2='L2' - Lambda3='L3' - Lambda4='L4' - re_Lambda5='re_L5' - im_Lambda5='im_L5' - tanbeta='tbeta' - re_m12squared='re_m12sq' - - with open(InputFile, 'r') as file: - df = pd.read_csv(file,index_col=HasIndexCol,sep=Separator) - - frontcol=[Type,Lambda1,Lambda2,Lambda3,Lambda4,re_Lambda5,im_Lambda5,re_m12squared,tanbeta] + print(f"Reading {InputFile}.") + print(f"Output is saved to {OutputFile}.") + + HasIndexCol = False + Separator = "\t" + Type = "yuktype" + Lambda1 = "L1" + Lambda2 = "L2" + Lambda3 = "L3" + Lambda4 = "L4" + re_Lambda5 = "re_L5" + im_Lambda5 = "im_L5" + tanbeta = "tbeta" + re_m12squared = "re_m12sq" + + with open(InputFile, "r") as file: + df = pd.read_csv(file, index_col=HasIndexCol, sep=Separator) + + frontcol = [ + Type, + Lambda1, + Lambda2, + Lambda3, + Lambda4, + re_Lambda5, + im_Lambda5, + re_m12squared, + tanbeta, + ] Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] df = df[Col] - with open(OutputFile, 'w') as file: - df.to_csv(file, index=False, sep='\t') + with open(OutputFile, "w") as file: + df.to_csv(file, index=False, sep="\t") + if __name__ == "__main__": convert(sys.argv[1], sys.argv[2]) diff --git a/sh/prepareData_CxSM.py b/sh/prepareData_CxSM.py index 2d22d770..2214e802 100755 --- a/sh/prepareData_CxSM.py +++ b/sh/prepareData_CxSM.py @@ -6,55 +6,57 @@ import pandas as pd import sys + def convert(InputFile, OutputFile): - print(f'Reading {InputFile}.') - print(f'Output is saved to {OutputFile}.') - - with open(InputFile, 'r') as file: - df = pd.read_csv(file,index_col=False,sep='\t') - - v = 'v' - vs = 'vs' - va = 'va' - msq = 'msq' - lamb = 'lambda' - delta2 = 'delta2' - b2 = 'b2' - d2 = 'd2' - Reb1 = 'Reb1' - Imb1 = 'Imb1' - Rea1 = 'Rea1' - Ima1 = 'Ima1' - - NoImb1 = False - NoIma1 = False - - if Imb1 not in df: - Reb1 = 'b1' - print(f'Reb1 changed to {Reb1}.') - NoImb1 = True - if Ima1 not in df: - Rea1 = 'a1' - print(f'Rea1 changed to {Rea1}.') - NoIma1 = True - - frontcol=[v, vs, va, msq, lamb, delta2, b2, d2, Reb1, Imb1, Rea1, Ima1] - - for c in frontcol: - if c not in df: - df[c] = 0 - - Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] - - df = df[Col] - - if NoImb1: - df.rename(columns={Reb1:'Reb1'}, inplace=True) - if NoIma1: - df.rename(columns={Rea1:'Rea1'}, inplace=True) - - with open(OutputFile, 'w') as file: - df.to_csv(file, index=True, sep='\t')\ + print(f"Reading {InputFile}.") + print(f"Output is saved to {OutputFile}.") + + with open(InputFile, "r") as file: + df = pd.read_csv(file, index_col=False, sep="\t") + + v = "v" + vs = "vs" + va = "va" + msq = "msq" + lamb = "lambda" + delta2 = "delta2" + b2 = "b2" + d2 = "d2" + Reb1 = "Reb1" + Imb1 = "Imb1" + Rea1 = "Rea1" + Ima1 = "Ima1" + + NoImb1 = False + NoIma1 = False + + if Imb1 not in df: + Reb1 = "b1" + print(f"Reb1 changed to {Reb1}.") + NoImb1 = True + if Ima1 not in df: + Rea1 = "a1" + print(f"Rea1 changed to {Rea1}.") + NoIma1 = True + + frontcol = [v, vs, va, msq, lamb, delta2, b2, d2, Reb1, Imb1, Rea1, Ima1] + + for c in frontcol: + if c not in df: + df[c] = 0 + + Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] + + df = df[Col] + + if NoImb1: + df.rename(columns={Reb1: "Reb1"}, inplace=True) + if NoIma1: + df.rename(columns={Rea1: "Rea1"}, inplace=True) + + with open(OutputFile, "w") as file: + df.to_csv(file, index=True, sep="\t") + if __name__ == "__main__": convert(sys.argv[1], sys.argv[2]) diff --git a/sh/prepareData_N2HDM.py b/sh/prepareData_N2HDM.py index 307b7be7..0f4a3fd5 100644 --- a/sh/prepareData_N2HDM.py +++ b/sh/prepareData_N2HDM.py @@ -5,43 +5,63 @@ import pandas as pd import argparse -####### The parameters Type,Lambda1 to Lambda8, tanbeta, m12squared and v_s should have the label of the +####### The parameters Type,Lambda1 to Lambda8, tanbeta, m12squared and v_s should have the label of the ####### corresponding parameter. With Seperator you have to tell which seperator your data file ####### is using (e.g. , \t or space). Your InputFILE will then be saved to OutputFILE. -Seperator='\t' -InputFILE='../example/N2HDM_Input.dat' -OutputFILE='N2HDM_Ordered.dat' -Type='p_THDMtype' -Lambda1='p_L1' -Lambda2='p_L2' -Lambda3='p_L3' -Lambda4='p_L4' -Lambda5='p_L5' -Lambda6='p_L6' -Lambda7='p_L7' -Lambda8='p_L8' -tanbeta='p_tbeta' -m12squared='p_m12sq' -vs='p_vs' +Seperator = "\t" +InputFILE = "../example/N2HDM_Input.dat" +OutputFILE = "N2HDM_Ordered.dat" +Type = "p_THDMtype" +Lambda1 = "p_L1" +Lambda2 = "p_L2" +Lambda3 = "p_L3" +Lambda4 = "p_L4" +Lambda5 = "p_L5" +Lambda6 = "p_L6" +Lambda7 = "p_L7" +Lambda8 = "p_L8" +tanbeta = "p_tbeta" +m12squared = "p_m12sq" +vs = "p_vs" + def convert(IndexCol): - df=pd.DataFrame() - if IndexCol == 'False': - df=pd.read_table(InputFILE,index_col=False,sep=Seperator) - else: - df=pd.read_table(InputFILE,index_col=int(IndexCol),sep=Seperator) + df = pd.DataFrame() + if IndexCol == "False": + df = pd.read_table(InputFILE, index_col=False, sep=Seperator) + else: + df = pd.read_table(InputFILE, index_col=int(IndexCol), sep=Seperator) + + frontcol = [ + Type, + Lambda1, + Lambda2, + Lambda3, + Lambda4, + Lambda5, + Lambda6, + Lambda7, + Lambda8, + vs, + tanbeta, + m12squared, + ] - frontcol=[Type,Lambda1,Lambda2,Lambda3,Lambda4,Lambda5,Lambda6,Lambda7,Lambda8,vs,tanbeta,m12squared] + Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] + df = df[Col] - Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] - df=df[Col] + df.to_csv(OutputFILE, index=False, sep="\t") - df.to_csv(OutputFILE,index=False,sep='\t') parser = argparse.ArgumentParser() -parser.add_argument('-i','--indexcol',help='Column which stores the index of your data', default='False') +parser.add_argument( + "-i", + "--indexcol", + help="Column which stores the index of your data", + default="False", +) if __name__ == "__main__": - args = parser.parse_args() - convert(args.indexcol) \ No newline at end of file + args = parser.parse_args() + convert(args.indexcol) diff --git a/sh/prepareData_R2HDM.py b/sh/prepareData_R2HDM.py index ff08ed6e..3db06c67 100755 --- a/sh/prepareData_R2HDM.py +++ b/sh/prepareData_R2HDM.py @@ -6,35 +6,37 @@ import pandas as pd import sys -####### The parameters Type, Lambda1 to Lambda5, tanbeta and m12squared should have the label of the corresponding +####### The parameters Type, Lambda1 to Lambda5, tanbeta and m12squared should have the label of the corresponding ####### parameter. With Seperator you have to tell which seperator your data file ####### is using (e.g. , \t or space). Your InputFILE will then be saved to OutputFILE + def convert(InputFile, OutputFile): - print(f'Reading {InputFile}.') - print(f'Output is saved to {OutputFile}.') + print(f"Reading {InputFile}.") + print(f"Output is saved to {OutputFile}.") - HasIndexCol=False - Separator='\t' - Type='yuktype' - Lambda1='L1' - Lambda2='L2' - Lambda3='L3' - Lambda4='L4' - Lambda5='L5' - tanbeta='tbeta' - m12squared='m12sq' + HasIndexCol = False + Separator = "\t" + Type = "yuktype" + Lambda1 = "L1" + Lambda2 = "L2" + Lambda3 = "L3" + Lambda4 = "L4" + Lambda5 = "L5" + tanbeta = "tbeta" + m12squared = "m12sq" - with open(InputFile, 'r') as file: - df = pd.read_csv(file,index_col=HasIndexCol,sep=Separator) + with open(InputFile, "r") as file: + df = pd.read_csv(file, index_col=HasIndexCol, sep=Separator) - frontcol=[Type,Lambda1,Lambda2,Lambda3,Lambda4,Lambda5,m12squared,tanbeta] + frontcol = [Type, Lambda1, Lambda2, Lambda3, Lambda4, Lambda5, m12squared, tanbeta] Col = [c for c in frontcol if c in df] + [c for c in df if c not in frontcol] df = df[Col] - with open(OutputFile, 'w') as file: - df.to_csv(file, index=False, sep='\t') + with open(OutputFile, "w") as file: + df.to_csv(file, index=False, sep="\t") + if __name__ == "__main__": convert(sys.argv[1], sys.argv[2]) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 00000000..53e37878 --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.23) +project(PackageTest CXX) + +find_package(BSMPT CONFIG REQUIRED) + +add_executable(example src/example.cpp) +target_link_libraries(example bsmpt::utility) \ No newline at end of file diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 00000000..4c065a48 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,29 @@ + + +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class helloTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") + diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp new file mode 100644 index 00000000..0d257495 --- /dev/null +++ b/test_package/src/example.cpp @@ -0,0 +1,5 @@ +#include "hello.h" + +int main() { + hello(); +} diff --git a/tools/ModelGeneration/sympy/General2HDM.py b/tools/ModelGeneration/sympy/General2HDM.py index 288da6ad..7dc14770 100644 --- a/tools/ModelGeneration/sympy/General2HDM.py +++ b/tools/ModelGeneration/sympy/General2HDM.py @@ -1,4 +1,4 @@ -from sympy import symbols, Matrix, simplify, I, sqrt, im , conjugate, expand +from sympy import symbols, Matrix, simplify, I, sqrt, im, conjugate, expand from sympy.physics.quantum import Dagger from enum import Enum @@ -7,165 +7,233 @@ class TwoHDMType(Enum): - TypeI=0, - TypeII=1, - Flipped=2, - LeptonSpecific=3 + TypeI = (0,) + TypeII = (1,) + Flipped = (2,) + LeptonSpecific = 3 + Chosen2HDMType = TwoHDMType.TypeI # SM paramters -Cg = symbols('C_g',real=True) -Cgs = symbols('C_gs',real=True) -sigma0 = Matrix([[1,0],[0,1]]) -sigma1 = Matrix([[0,1],[1,0]]) -sigma2 = Matrix([[0,-I],[I,0]]) -sigma3 = Matrix([[1,0],[0,-1]]) -m_electron = symbols('C_MassElectron',real=True) -m_mu = symbols('C_MassMu',real=True) -m_tau = symbols('C_MassTau',real=True) -m_up = symbols('C_MassUp',real=True) -m_charm = symbols('C_MassCharm',real=True) -m_top = symbols('C_MassTop',real=True) -m_down = symbols('C_MassDown',real=True) -m_strange = symbols('C_MassStrange',real=True) -m_bottom = symbols('C_MassBottom',real=True) - +Cg = symbols("C_g", real=True) +Cgs = symbols("C_gs", real=True) +sigma0 = Matrix([[1, 0], [0, 1]]) +sigma1 = Matrix([[0, 1], [1, 0]]) +sigma2 = Matrix([[0, -I], [I, 0]]) +sigma3 = Matrix([[1, 0], [0, -1]]) +m_electron = symbols("C_MassElectron", real=True) +m_mu = symbols("C_MassMu", real=True) +m_tau = symbols("C_MassTau", real=True) +m_up = symbols("C_MassUp", real=True) +m_charm = symbols("C_MassCharm", real=True) +m_top = symbols("C_MassTop", real=True) +m_down = symbols("C_MassDown", real=True) +m_strange = symbols("C_MassStrange", real=True) +m_bottom = symbols("C_MassBottom", real=True) # CKM Matrix -Vud,Vus,Vub,Vcd,Vcs,Vcb,Vtd,Vts,Vtb = symbols('Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb') -VCKM = Matrix([[Vud,Vus,Vub],[Vcd,Vcs,Vcb],[Vtd,Vts,Vtb]]) - -#parameters -m11sq, m22sq, Rem12sq, Imm12sq = symbols('m11sq m22sq Rem12sq Imm12sq',real=True) -lambda1 = symbols('lambda1',real=True) -lambda2 = symbols('lambda2',real=True) -lambda3 = symbols('lambda3',real=True) -lambda4 = symbols('lambda4',real=True) -Relambda5 = symbols('Relambda5',real=True) -Imlambda5 = symbols('Imlambda5',real=True) -Relambda6 = symbols('Relambda6',real=True) -Imlambda6 = symbols('Imlambda6',real=True) -Relambda7 = symbols('Relambda7',real=True) -Imlambda7 = symbols('Imlambda7',real=True) - -m12sq = Rem12sq + I *Imm12sq -lambda5 = Relambda5 + I*Imlambda5 -lambda6 = Relambda6 + I*Imlambda6 -lambda7 = Relambda7 + I*Imlambda7 - -params=[lambda1,lambda2,lambda3,lambda4,Relambda5,Imlambda5,Relambda6,Imlambda6,Relambda7,Imlambda7,m11sq,m22sq,Rem12sq,Imm12sq] - -#CT params -dm11sq, dm22sq, dRem12sq, dImm12sq = symbols('dm11sq dm22sq dRem12sq dImm12sq',real=True) -dlambda1 = symbols('dlambda1',real=True) -dlambda2 = symbols('dlambda2',real=True) -dlambda3 = symbols('dlambda3',real=True) -dlambda4 = symbols('dlambda4',real=True) -dRelambda5 = symbols('dRelambda5',real=True) -dImlambda5 = symbols('dImlambda5',real=True) -dRelambda6 = symbols('dRelambda6',real=True) -dImlambda6 = symbols('dImlambda6',real=True) -dRelambda7 = symbols('dRelambda7',real=True) -dImlambda7 = symbols('dImlambda7',real=True) -dparams=[dlambda1,dlambda2,dlambda3,dlambda4,dRelambda5,dImlambda5,dRelambda6,dImlambda6,dRelambda7,dImlambda7,dm11sq,dm22sq,dRem12sq,dImm12sq] - -#VEVs -v1 = symbols('v1', real=True) -v2 = symbols('v2', real=True) -w1 = symbols('w1' , real=True) -w2 = symbols('w2' , real=True) -wCP = symbols('wCP',real=True) -wCB = symbols('wCB',real=True) - -#Higgsfields -rho1,eta1,zeta1,psi1 = symbols('rho1 eta1 zeta1 psi1', real=True) -rho2,eta2,zeta2,psi2 = symbols('rho2 eta2 zeta2 psi2', real=True) -Higgsfields=[rho1,eta1,rho2,eta2,zeta1,psi1,zeta2,psi2] -CTTadpoles = symbols('dT1:{}'.format(len(Higgsfields)+1),real=True) - -#doublets -phi1 = Matrix([[Higgsfields[0]+I*Higgsfields[1]], [Higgsfields[4]+I*Higgsfields[5]]]) * 1/sqrt(2) -phi2 = Matrix([[Higgsfields[2]+I*Higgsfields[3]], [Higgsfields[6]+I*Higgsfields[7]]]) * 1/sqrt(2) - -#replacements -higgsvevAtZeroTemp = [0,0,0,0,v1,0,v2,0] -higgsVEVAtFiniteTemp = [0,0,wCB, 0, w1, 0, w2, wCP] -zeroTempVEV = [(Higgsfields[i],higgsvevAtZeroTemp[i]) for i in range(len(Higgsfields)) ] -finiteTempVEV = [(Higgsfields[i],higgsVEVAtFiniteTemp[i]) for i in range(len(Higgsfields)) ] -fieldsZero = [(x,0) for x in Higgsfields] - -phi1Sq = simplify((Dagger(phi1)*phi1)[0]) -phi2Sq = simplify((Dagger(phi2)*phi2)[0]) -phi12 = simplify((Dagger(phi1)*phi2)[0]) -phi21 = simplify((Dagger(phi2)*phi1)[0]) +Vud, Vus, Vub, Vcd, Vcs, Vcb, Vtd, Vts, Vtb = symbols( + "Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb" +) +VCKM = Matrix([[Vud, Vus, Vub], [Vcd, Vcs, Vcb], [Vtd, Vts, Vtb]]) + +# parameters +m11sq, m22sq, Rem12sq, Imm12sq = symbols("m11sq m22sq Rem12sq Imm12sq", real=True) +lambda1 = symbols("lambda1", real=True) +lambda2 = symbols("lambda2", real=True) +lambda3 = symbols("lambda3", real=True) +lambda4 = symbols("lambda4", real=True) +Relambda5 = symbols("Relambda5", real=True) +Imlambda5 = symbols("Imlambda5", real=True) +Relambda6 = symbols("Relambda6", real=True) +Imlambda6 = symbols("Imlambda6", real=True) +Relambda7 = symbols("Relambda7", real=True) +Imlambda7 = symbols("Imlambda7", real=True) + +m12sq = Rem12sq + I * Imm12sq +lambda5 = Relambda5 + I * Imlambda5 +lambda6 = Relambda6 + I * Imlambda6 +lambda7 = Relambda7 + I * Imlambda7 + +params = [ + lambda1, + lambda2, + lambda3, + lambda4, + Relambda5, + Imlambda5, + Relambda6, + Imlambda6, + Relambda7, + Imlambda7, + m11sq, + m22sq, + Rem12sq, + Imm12sq, +] + +# CT params +dm11sq, dm22sq, dRem12sq, dImm12sq = symbols( + "dm11sq dm22sq dRem12sq dImm12sq", real=True +) +dlambda1 = symbols("dlambda1", real=True) +dlambda2 = symbols("dlambda2", real=True) +dlambda3 = symbols("dlambda3", real=True) +dlambda4 = symbols("dlambda4", real=True) +dRelambda5 = symbols("dRelambda5", real=True) +dImlambda5 = symbols("dImlambda5", real=True) +dRelambda6 = symbols("dRelambda6", real=True) +dImlambda6 = symbols("dImlambda6", real=True) +dRelambda7 = symbols("dRelambda7", real=True) +dImlambda7 = symbols("dImlambda7", real=True) +dparams = [ + dlambda1, + dlambda2, + dlambda3, + dlambda4, + dRelambda5, + dImlambda5, + dRelambda6, + dImlambda6, + dRelambda7, + dImlambda7, + dm11sq, + dm22sq, + dRem12sq, + dImm12sq, +] + +# VEVs +v1 = symbols("v1", real=True) +v2 = symbols("v2", real=True) +w1 = symbols("w1", real=True) +w2 = symbols("w2", real=True) +wCP = symbols("wCP", real=True) +wCB = symbols("wCB", real=True) + +# Higgsfields +rho1, eta1, zeta1, psi1 = symbols("rho1 eta1 zeta1 psi1", real=True) +rho2, eta2, zeta2, psi2 = symbols("rho2 eta2 zeta2 psi2", real=True) +Higgsfields = [rho1, eta1, rho2, eta2, zeta1, psi1, zeta2, psi2] +CTTadpoles = symbols("dT1:{}".format(len(Higgsfields) + 1), real=True) + +# doublets +phi1 = ( + Matrix( + [[Higgsfields[0] + I * Higgsfields[1]], [Higgsfields[4] + I * Higgsfields[5]]] + ) + * 1 + / sqrt(2) +) +phi2 = ( + Matrix( + [[Higgsfields[2] + I * Higgsfields[3]], [Higgsfields[6] + I * Higgsfields[7]]] + ) + * 1 + / sqrt(2) +) + +# replacements +higgsvevAtZeroTemp = [0, 0, 0, 0, v1, 0, v2, 0] +higgsVEVAtFiniteTemp = [0, 0, wCB, 0, w1, 0, w2, wCP] +zeroTempVEV = [(Higgsfields[i], higgsvevAtZeroTemp[i]) for i in range(len(Higgsfields))] +finiteTempVEV = [ + (Higgsfields[i], higgsVEVAtFiniteTemp[i]) for i in range(len(Higgsfields)) +] +fieldsZero = [(x, 0) for x in Higgsfields] + +phi1Sq = simplify((Dagger(phi1) * phi1)[0]) +phi2Sq = simplify((Dagger(phi2) * phi2)[0]) +phi12 = simplify((Dagger(phi1) * phi2)[0]) +phi21 = simplify((Dagger(phi2) * phi1)[0]) phi12Sq = simplify(phi12**2) phi21Sq = simplify(phi21**2) -VHiggsNC = m11sq*phi1Sq+ m22sq * phi2Sq + lambda1/2 * phi1Sq**2 +lambda2/2 * phi2Sq**2 + lambda3*phi1Sq*phi2Sq + lambda4*phi12*phi21 +VHiggsNC = ( + m11sq * phi1Sq + + m22sq * phi2Sq + + lambda1 / 2 * phi1Sq**2 + + lambda2 / 2 * phi2Sq**2 + + lambda3 * phi1Sq * phi2Sq + + lambda4 * phi12 * phi21 +) # We need to expand here otherwise simplify cant handle the simplification well enough -VHiggsHC = expand(-m12sq*phi12 + lambda5/2 *phi12**2 + lambda6*phi1Sq*phi12 + lambda7*phi2Sq*phi12) +VHiggsHC = expand( + -m12sq * phi12 + + lambda5 / 2 * phi12**2 + + lambda6 * phi1Sq * phi12 + + lambda7 * phi2Sq * phi12 +) VHiggs = simplify(VHiggsNC + VHiggsHC + conjugate(VHiggsHC)) if im(VHiggs) != 0: raise Exception("Higgs potential has an imaginary part with " + str(im(VHiggs))) # Generate the model -G2HDM = ModelGenerator.ModelGenerator(params,dparams,CTTadpoles,Higgsfields,VHiggs,zeroTempVEV, finiteTempVEV) - - +G2HDM = ModelGenerator.ModelGenerator( + params, dparams, CTTadpoles, Higgsfields, VHiggs, zeroTempVEV, finiteTempVEV +) # Set Gauge fields -W1, W2, W3, B0 = symbols('W1 W2 W3 B0',real=True) +W1, W2, W3, B0 = symbols("W1 W2 W3 B0", real=True) -Dmu = -I*Cg/2 * (sigma1*W1 + sigma2 * W2 + sigma3*W3) -I*Cgs/2 * sigma0 * B0 -VGauge = simplify(Dagger(Dmu*phi1)*(Dmu*phi1))[0,0] + simplify(Dagger(Dmu*phi2)*(Dmu*phi2))[0,0] +Dmu = ( + -I * Cg / 2 * (sigma1 * W1 + sigma2 * W2 + sigma3 * W3) - I * Cgs / 2 * sigma0 * B0 +) +VGauge = ( + simplify(Dagger(Dmu * phi1) * (Dmu * phi1))[0, 0] + + simplify(Dagger(Dmu * phi2) * (Dmu * phi2))[0, 0] +) # Generate Lepton Potentials -NuL = symbols('veL vmuL vtauL',real=True) -ER = symbols('eR muR tauR', real=True) -EL = symbols('eL muL tauL', real=True) +NuL = symbols("veL vmuL vtauL", real=True) +ER = symbols("eR muR tauR", real=True) +EL = symbols("eL muL tauL", real=True) LepBase = NuL + ER + EL + + def TypeILeptons(): - ye = sqrt(2)*m_electron/v2 - ymu = sqrt(2)*m_mu/v2 - ytau = sqrt(2)*m_tau/v2 + ye = sqrt(2) * m_electron / v2 + ymu = sqrt(2) * m_mu / v2 + ytau = sqrt(2) * m_tau / v2 - PiLep = Matrix([[ye,0,0],[0,ymu,0],[0,0,ytau]]) + PiLep = Matrix([[ye, 0, 0], [0, ymu, 0], [0, 0, ytau]]) VFLep = 0 for i in range(len(NuL)): for j in range(len(ER)): - VFLep += (NuL[i] * PiLep[i,j] * ER[j])*phi2[0] + VFLep += (NuL[i] * PiLep[i, j] * ER[j]) * phi2[0] for i in range(len(EL)): for j in range(len(ER)): - VFLep += (EL[i] * PiLep[i,j] * ER[j])*phi2[1] + VFLep += (EL[i] * PiLep[i, j] * ER[j]) * phi2[1] VFLep = simplify(VFLep) - return VFLep + return VFLep + def TypeIILeptons(): - ye = sqrt(2)*m_electron/v1 - ymu = sqrt(2)*m_mu/v1 - ytau = sqrt(2)*m_tau/v1 + ye = sqrt(2) * m_electron / v1 + ymu = sqrt(2) * m_mu / v1 + ytau = sqrt(2) * m_tau / v1 - PiLep = Matrix([[ye,0,0],[0,ymu,0],[0,0,ytau]]) + PiLep = Matrix([[ye, 0, 0], [0, ymu, 0], [0, 0, ytau]]) VFLep = 0 for i in range(len(NuL)): for j in range(len(ER)): - VFLep += (NuL[i] * PiLep[i,j] * ER[j])*phi1[1] + VFLep += (NuL[i] * PiLep[i, j] * ER[j]) * phi1[1] for i in range(len(EL)): for j in range(len(ER)): - VFLep += (EL[i] * PiLep[i,j] * ER[j])*phi1[0] + VFLep += (EL[i] * PiLep[i, j] * ER[j]) * phi1[0] VFLep = simplify(VFLep) return VFLep @@ -177,91 +245,99 @@ def TypeIILeptons(): VFLep = TypeIILeptons() - - - - - # Generate Quark Potentials -UL = symbols('uL cL tL', real=True) -DL = symbols('dL sL bL', real=True) -UR = symbols('uR cR tR', real=True) -DR = symbols('dR sR bR', real=True) +UL = symbols("uL cL tL", real=True) +DL = symbols("dL sL bL", real=True) +UR = symbols("uR cR tR", real=True) +DR = symbols("dR sR bR", real=True) QuarkBase = UR + DR + UL + DL + def TypeIQuarks(): - yb = sqrt(2)*m_bottom/v2 - yc = sqrt(2)*m_charm/v2 - yd = sqrt(2)*m_down/v2 - ys = sqrt(2)*m_strange/v2 - yt = sqrt(2)*m_top/v2 - yu = sqrt(2)*m_up/v2 + yb = sqrt(2) * m_bottom / v2 + yc = sqrt(2) * m_charm / v2 + yd = sqrt(2) * m_down / v2 + ys = sqrt(2) * m_strange / v2 + yt = sqrt(2) * m_top / v2 + yu = sqrt(2) * m_up / v2 - DownCoupling = Matrix([[yd,0,0],[0,ys,0],[0,0,yb]]) - UpCoupling = Matrix([[yu,0,0],[0,yc,0],[0,0,yt]]) + DownCoupling = Matrix([[yd, 0, 0], [0, ys, 0], [0, 0, yb]]) + UpCoupling = Matrix([[yu, 0, 0], [0, yc, 0], [0, 0, yt]]) ULVector = Matrix([[x] for x in UL]) DLVector = Matrix([[x] for x in DL]) URVector = Matrix([[x] for x in UR]) DRVector = Matrix([[x] for x in DR]) - phiUp = phi2 + phiUp = phi2 phiDown = phi2 VQuark = ULVector.transpose() * VCKM * DownCoupling * DRVector * phiDown[0] - VQuark+= DLVector.transpose() * DownCoupling * DRVector * phiDown[1] + VQuark += DLVector.transpose() * DownCoupling * DRVector * phiDown[1] VQuark += ULVector.transpose() * UpCoupling * URVector * phiUp[1].conjugate() - VQuark+= -DLVector.transpose() * Dagger(VCKM)*UpCoupling*URVector*phiUp[0].conjugate() - VQuark = simplify(VQuark[0,0]) + VQuark += ( + -DLVector.transpose() + * Dagger(VCKM) + * UpCoupling + * URVector + * phiUp[0].conjugate() + ) + VQuark = simplify(VQuark[0, 0]) return VQuark + def TypeIIQuarks(): - yb = sqrt(2)*m_bottom/v1 - yd = sqrt(2)*m_down/v1 - ys = sqrt(2)*m_strange/v1 + yb = sqrt(2) * m_bottom / v1 + yd = sqrt(2) * m_down / v1 + ys = sqrt(2) * m_strange / v1 - yt = sqrt(2)*m_top/v2 - yu = sqrt(2)*m_up/v2 - yc = sqrt(2)*m_charm/v2 + yt = sqrt(2) * m_top / v2 + yu = sqrt(2) * m_up / v2 + yc = sqrt(2) * m_charm / v2 - DownCoupling = Matrix([[yd,0,0],[0,ys,0],[0,0,yb]]) - UpCoupling = Matrix([[yu,0,0],[0,yc,0],[0,0,yt]]) + DownCoupling = Matrix([[yd, 0, 0], [0, ys, 0], [0, 0, yb]]) + UpCoupling = Matrix([[yu, 0, 0], [0, yc, 0], [0, 0, yt]]) ULVector = Matrix([[x] for x in UL]) DLVector = Matrix([[x] for x in DL]) URVector = Matrix([[x] for x in UR]) DRVector = Matrix([[x] for x in DR]) - phiUp = phi2 + phiUp = phi2 phiDown = phi1 VQuark = ULVector.transpose() * VCKM * DownCoupling * DRVector * phiDown[0] - VQuark+= DLVector.transpose() * DownCoupling * DRVector * phiDown[1] + VQuark += DLVector.transpose() * DownCoupling * DRVector * phiDown[1] VQuark += ULVector.transpose() * UpCoupling * URVector * phiUp[1].conjugate() - VQuark+= -DLVector.transpose() * Dagger(VCKM)*UpCoupling*URVector*phiUp[0].conjugate() - VQuark = simplify(VQuark[0,0]) + VQuark += ( + -DLVector.transpose() + * Dagger(VCKM) + * UpCoupling + * URVector + * phiUp[0].conjugate() + ) + VQuark = simplify(VQuark[0, 0]) return VQuark + if Chosen2HDMType == TwoHDMType.TypeII or Chosen2HDMType == TwoHDMType.Flipped: VQuark = TypeIIQuarks() else: VQuark = TypeIQuarks() - - # Get the tesnors -G2HDM.setGauge([W1,W2,W3,B0],VGauge) +G2HDM.setGauge([W1, W2, W3, B0], VGauge) G2HDM.setLepton(LepBase, VFLep) G2HDM.setQuark(QuarkBase, VQuark) def setAdditionalCTEquations(): - # additional equations to define a unique CT solution point + # additional equations to define a unique CT solution point additionaEquations = [] additionaEquations.append(dlambda4) additionaEquations.append(dRelambda7) @@ -270,16 +346,21 @@ def setAdditionalCTEquations(): return additionaEquations - parser = argparse.ArgumentParser() -parser.add_argument('-s','--show',choices=['ct','tensor','treeSimpl','CTSimpl'],required=True,help='The part of the model to be printed') +parser.add_argument( + "-s", + "--show", + choices=["ct", "tensor", "treeSimpl", "CTSimpl"], + required=True, + help="The part of the model to be printed", +) if __name__ == "__main__": args = parser.parse_args() method = args.show - printCT = method == 'ct' - printTensors = method == 'tensor' + printCT = method == "ct" + printTensors = method == "tensor" if printCT: print("//Begin CT Calculation") @@ -293,8 +374,8 @@ def setAdditionalCTEquations(): if printTensors: G2HDM.printModelToCPP() - if method == 'treeSimpl': + if method == "treeSimpl": G2HDM.printTreeSimplified() - - if method == 'CTSimpl': - G2HDM.printVCTSimplified() \ No newline at end of file + + if method == "CTSimpl": + G2HDM.printVCTSimplified() diff --git a/tools/ModelGeneration/sympy/ModelGenerator.py b/tools/ModelGeneration/sympy/ModelGenerator.py index 9e5fbc39..9c5d8f2d 100644 --- a/tools/ModelGeneration/sympy/ModelGenerator.py +++ b/tools/ModelGeneration/sympy/ModelGenerator.py @@ -1,12 +1,24 @@ -from sympy import symbols, Matrix, diff, simplify, Symbol, linsolve, I, hessian, zeros, expand +from sympy import ( + symbols, + Matrix, + diff, + simplify, + Symbol, + linsolve, + I, + hessian, + zeros, + expand, +) from sympy.printing.cxx import cxxcode + class ModelGenerator: - _params =None - _dparams = None + _params = None + _dparams = None _CTTadpoles = None _HiggsFields = None - _VHiggs =None + _VHiggs = None _nHiggs = 0 _VCT = None _NablaVCW = None @@ -23,8 +35,18 @@ class ModelGenerator: _QuarkFields = [] _nQuarks = 0 _VQuarks = 0 - _CTParVectorOrder=[] - def __init__(self, params, dparams,CTTadpoles,HiggsFields,VHiggs,VEVAtZeroTemp,finiteTempVEV): + _CTParVectorOrder = [] + + def __init__( + self, + params, + dparams, + CTTadpoles, + HiggsFields, + VHiggs, + VEVAtZeroTemp, + finiteTempVEV, + ): self._params = params self._dparams = dparams self._CTTadpoles = CTTadpoles @@ -33,25 +55,46 @@ def __init__(self, params, dparams,CTTadpoles,HiggsFields,VHiggs,VEVAtZeroTemp,f self._nHiggs = len(HiggsFields) self._VEVAtZeroTemp = VEVAtZeroTemp self._calcVCT() - self._NablaVCW = Matrix([[Symbol("NCW[{},{}]".format(i,j),real=True) for j in range(1)] for i in range(self._nHiggs) ]) - self._HessianVCW = Matrix([[Symbol("HCW[{},{}]".format(i,j),real=True) for j in range(self._nHiggs)] for i in range(self._nHiggs) ]) + self._NablaVCW = Matrix( + [ + [Symbol("NCW[{},{}]".format(i, j), real=True) for j in range(1)] + for i in range(self._nHiggs) + ] + ) + self._HessianVCW = Matrix( + [ + [ + Symbol("HCW[{},{}]".format(i, j), real=True) + for j in range(self._nHiggs) + ] + for i in range(self._nHiggs) + ] + ) self._TreeLevelTadpoleReplacement = None self._calcTreeLevelMinimumConditions() self._VEVAtFiniteTemp = finiteTempVEV - counter=0 + counter = 0 for i in range(self._nHiggs): - self._replacementLists['NCW[' + str(i) + ']'] = 'NablaWeinberg(' + str(i) + ')' + self._replacementLists["NCW[" + str(i) + "]"] = ( + "NablaWeinberg(" + str(i) + ")" + ) for j in range(self._nHiggs): - self._replacementLists['HCW[' + str(counter) + ']'] = 'HesseWeinberg(' + str(i) + "," + str(j) + ")" + self._replacementLists["HCW[" + str(counter) + "]"] = ( + "HesseWeinberg(" + str(i) + "," + str(j) + ")" + ) counter += 1 - + for i in range(self._nHiggs): - self._replacementLists['NCW[' + str(i) + ',0]'] = 'NablaWeinberg(' + str(i) + ')' + self._replacementLists["NCW[" + str(i) + ",0]"] = ( + "NablaWeinberg(" + str(i) + ")" + ) for j in range(self._nHiggs): - self._replacementLists['HCW[' + str(i) + ',' + str(j) + "]"] = 'HesseWeinberg(' + str(i) + "," + str(j) + ")" + self._replacementLists["HCW[" + str(i) + "," + str(j) + "]"] = ( + "HesseWeinberg(" + str(i) + "," + str(j) + ")" + ) - def setGauge(self,gaugeFields, VGauge): + def setGauge(self, gaugeFields, VGauge): self._GaugeFields = gaugeFields self._VGauge = VGauge self._nGauge = len(gaugeFields) @@ -67,79 +110,136 @@ def setQuark(self, quarkFields, VQuarks): self._QuarkFields = quarkFields def printVEVOrder(self): - vevCounter=0 + vevCounter = 0 for i in range(self._nHiggs): val = self._VEVAtFiniteTemp[i][1] - if(val != 0): + if val != 0: print("VevOrder.at(" + str(vevCounter) + ") = " + str(i) + ";") - vevCounter+=1 + vevCounter += 1 def _calcTreeLevelMinimumConditions(self): gradient = lambda f, v: Matrix([f]).jacobian(v) - NablaV=simplify(gradient(self._VHiggs,self._HiggsFields).subs(self._VEVAtZeroTemp)) - n,m = NablaV.shape - Equations= [NablaV[i,j] for i in range(n) for j in range(m) if NablaV[i,j] != 0] - self._TreeLevelTadpoleReplacement = linsolve(Equations,self._params) + NablaV = simplify( + gradient(self._VHiggs, self._HiggsFields).subs(self._VEVAtZeroTemp) + ) + n, m = NablaV.shape + Equations = [ + NablaV[i, j] for i in range(n) for j in range(m) if NablaV[i, j] != 0 + ] + self._TreeLevelTadpoleReplacement = linsolve(Equations, self._params) self._TreeLevelTadpoleReplacement = self._TreeLevelTadpoleReplacement.args[0] - def printTreeLevelMinimumConditions(self): for i in range(len(self._params)): - print(self.convertToCPP(self._params[i]) + " = " + self.convertToCPP(self._TreeLevelTadpoleReplacement[i]) + ";") - - def _printTensorsBasic(self,potential,tensorNamePrefix): - fieldsZero = [(x,0) for x in self._HiggsFields] + print( + self.convertToCPP(self._params[i]) + + " = " + + self.convertToCPP(self._TreeLevelTadpoleReplacement[i]) + + ";" + ) + + def _printTensorsBasic(self, potential, tensorNamePrefix): + fieldsZero = [(x, 0) for x in self._HiggsFields] for i in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i]) + val = diff(potential, self._HiggsFields[i]) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L1.at(" + str(i) + ") = " + self.convertToCPP(val) + ";") + print( + tensorNamePrefix + + "_L1.at(" + + str(i) + + ") = " + + self.convertToCPP(val) + + ";" + ) for i in range(self._nHiggs): for j in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i],self._HiggsFields[j]) + val = diff(potential, self._HiggsFields[i], self._HiggsFields[j]) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L2.at(" + str(i) + ").at(" + str(j) + ") = " + self.convertToCPP(val) + ";" ) + print( + tensorNamePrefix + + "_L2.at(" + + str(i) + + ").at(" + + str(j) + + ") = " + + self.convertToCPP(val) + + ";" + ) for i in range(self._nHiggs): for j in range(self._nHiggs): for k in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i],self._HiggsFields[j],self._HiggsFields[k]) + val = diff( + potential, + self._HiggsFields[i], + self._HiggsFields[j], + self._HiggsFields[k], + ) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L3.at(" + str(i) + ").at(" + str(j) + ").at("+ str(k) +") = " + self.convertToCPP(val) + ";" ) + print( + tensorNamePrefix + + "_L3.at(" + + str(i) + + ").at(" + + str(j) + + ").at(" + + str(k) + + ") = " + + self.convertToCPP(val) + + ";" + ) for i in range(self._nHiggs): for j in range(self._nHiggs): for k in range(self._nHiggs): for l in range(self._nHiggs): - val = diff(potential,self._HiggsFields[i],self._HiggsFields[j],self._HiggsFields[k],self._HiggsFields[l]) + val = diff( + potential, + self._HiggsFields[i], + self._HiggsFields[j], + self._HiggsFields[k], + self._HiggsFields[l], + ) val = val.subs(fieldsZero) val = simplify(val) if val != 0: - print(tensorNamePrefix+"_L4.at(" + str(i) + ").at(" + str(j) + ").at("+ str(k) +").at("+ str(l) +") = " + self.convertToCPP(val) + ";" ) - + print( + tensorNamePrefix + + "_L4.at(" + + str(i) + + ").at(" + + str(j) + + ").at(" + + str(k) + + ").at(" + + str(l) + + ") = " + + self.convertToCPP(val) + + ";" + ) def printTensors(self): - self._printTensorsBasic(self._VHiggs,"Curvature_Higgs") + self._printTensorsBasic(self._VHiggs, "Curvature_Higgs") def printCTTensors(self): - self._printTensorsBasic(self._VCT,"Curvature_Higgs_CT") - - - + self._printTensorsBasic(self._VCT, "Curvature_Higgs_CT") def _calcVCT(self): - self._VCT=0 + self._VCT = 0 for i in range(len(self._params)): - self._VCT = self._VCT + self._dparams[i]*diff(self._VHiggs,self._params[i]) + self._VCT = self._VCT + self._dparams[i] * diff( + self._VHiggs, self._params[i] + ) for i in range(len(self._HiggsFields)): - newTerm = self._CTTadpoles[i]*self._HiggsFields[i] + newTerm = self._CTTadpoles[i] * self._HiggsFields[i] self._VCT = self._VCT + newTerm self._VCT = simplify(self._VCT) @@ -147,56 +247,62 @@ def _calcVCT(self): def getVCT(self): return self._VCT - def _CTGetEquations(self): gradient = lambda f, v: Matrix([f]).jacobian(v) - NablaVCT=simplify(gradient(self._VCT,self._HiggsFields).subs(self._VEVAtZeroTemp)) - HessianVCT=simplify(hessian(self._VCT,self._HiggsFields).subs(self._VEVAtZeroTemp)) - - Equations=[] + NablaVCT = simplify( + gradient(self._VCT, self._HiggsFields).subs(self._VEVAtZeroTemp) + ) + HessianVCT = simplify( + hessian(self._VCT, self._HiggsFields).subs(self._VEVAtZeroTemp) + ) + + Equations = [] for i in range(self._nHiggs): val = NablaVCT[i] if val != 0: Equations.append(val + self._NablaVCW[i]) for i in range(self._nHiggs): - for j in range(i,self._nHiggs): - val = HessianVCT[i,j] + for j in range(i, self._nHiggs): + val = HessianVCT[i, j] if val != 0: - Equations.append(val+self._HessianVCW[i,j]) + Equations.append(val + self._HessianVCW[i, j]) return Equations def CTGetMatrixEquation(self): Equations = self._CTGetEquations() - dtParamsCombined=self._dparams+[x for x in self._CTTadpoles] - SysMatrix = zeros(len(Equations),len(dtParamsCombined)) - Target = zeros(len(Equations),1) + dtParamsCombined = self._dparams + [x for x in self._CTTadpoles] + SysMatrix = zeros(len(Equations), len(dtParamsCombined)) + Target = zeros(len(Equations), 1) for i in range(len(Equations)): - Target[i,0] = -Equations[i].subs([(x,0) for x in dtParamsCombined ]) + Target[i, 0] = -Equations[i].subs([(x, 0) for x in dtParamsCombined]) for j in range(len(dtParamsCombined)): - SysMatrix[i,j] = diff(Equations[i],dtParamsCombined[j]) - - + SysMatrix[i, j] = diff(Equations[i], dtParamsCombined[j]) - return SysMatrix,Target + return SysMatrix, Target - def calcCTParams(self,additionalEquations): + def calcCTParams(self, additionalEquations): EquationsFromSystem = self._CTGetEquations() Equations = EquationsFromSystem + additionalEquations - n,m = self._NablaVCW.shape - NVCWList = [self._NablaVCW[i,j] for i in range(n) for j in range(m)] - n,m = self._HessianVCW.shape - HVCWList = [self._HessianVCW[i,j] for i in range(n) for j in range(i,m)] - dtParamsCombined=self._dparams+[x for x in self._CTTadpoles] - extraArgs=NVCWList+HVCWList - combinedParams=dtParamsCombined+extraArgs - solution=linsolve(Equations,combinedParams) - solutionPairs = [(combinedParams[i], solution.args[0][i] ) for i in range(len(dtParamsCombined))] - identitiesPairs = [(combinedParams[i], solution.args[0][i] ) for i in range(len(dtParamsCombined),len(combinedParams))] - + n, m = self._NablaVCW.shape + NVCWList = [self._NablaVCW[i, j] for i in range(n) for j in range(m)] + n, m = self._HessianVCW.shape + HVCWList = [self._HessianVCW[i, j] for i in range(n) for j in range(i, m)] + dtParamsCombined = self._dparams + [x for x in self._CTTadpoles] + extraArgs = NVCWList + HVCWList + combinedParams = dtParamsCombined + extraArgs + solution = linsolve(Equations, combinedParams) + solutionPairs = [ + (combinedParams[i], solution.args[0][i]) + for i in range(len(dtParamsCombined)) + ] + identitiesPairs = [ + (combinedParams[i], solution.args[0][i]) + for i in range(len(dtParamsCombined), len(combinedParams)) + ] for eq in Equations: testedEquation = eq.subs(solutionPairs) @@ -205,11 +311,10 @@ def calcCTParams(self,additionalEquations): if testedEquation != 0: raise Exception("No solution for identities found") - uniqueSolutions = [] nonUniqueSolutions = [] for sol in solutionPairs: - isUnique = True + isUnique = True for par in self._dparams: if sol[1].diff(par) != 0: isUnique = False @@ -218,76 +323,130 @@ def calcCTParams(self,additionalEquations): uniqueSolutions.append(sol) else: nonUniqueSolutions.append(sol) - if len(nonUniqueSolutions) != 0: print("Non unique Solutions") - for lhs,rhs in nonUniqueSolutions: + for lhs, rhs in nonUniqueSolutions: print(str(lhs) + " = " + str(rhs)) - raise ValueError("You have non unique solutions in your system. Please define additional equations to choose among them.") + raise ValueError( + "You have non unique solutions in your system. Please define additional equations to choose among them." + ) - for par,val in solutionPairs: + for par, val in solutionPairs: self._CTParVectorOrder.append(par) return solutionPairs, identitiesPairs def convertToCPP(self, expr, assignTo=None): - II = symbols('II',real=True) + II = symbols("II", real=True) replExpr = "" try: - replExpr = expr.subs(I,II) + replExpr = expr.subs(I, II) except AttributeError: pass - custom_functions = { - 'conjugate': 'conj' - } + custom_functions = {"conjugate": "conj"} - code=cxxcode(replExpr, standard = 'C++17', user_functions = custom_functions, assign_to=assignTo) + code = cxxcode( + replExpr, + standard="C++17", + user_functions=custom_functions, + assign_to=assignTo, + ) strToPrint = str(code) - for key,value in self._replacementLists.items(): - strToPrint=strToPrint.replace(key,value) + for key, value in self._replacementLists.items(): + strToPrint = strToPrint.replace(key, value) return strToPrint - - - def printCTForCPP(self,additionalEquations=[]): + def printCTForCPP(self, additionalEquations=[]): CTPairs, identities = self.calcCTParams(additionalEquations) for par, val in CTPairs: - print("parCT.push_back("+ self.convertToCPP(val) + "); //" + self.convertToCPP(par)) - + print( + "parCT.push_back(" + + self.convertToCPP(val) + + "); //" + + self.convertToCPP(par) + ) def printCTOrder(self): for i in range(len(self._CTParVectorOrder)): par = self._CTParVectorOrder[i] - print(self.convertToCPP(par) + " = par.at(" + str(i) + ");" ) + print(self.convertToCPP(par) + " = par.at(" + str(i) + ");") def printGaugeTensors(self): for a in range(self._nGauge): for b in range(self._nGauge): for i in range(self._nHiggs): for j in range(self._nHiggs): - val = diff(self._VGauge,self._GaugeFields[a], self._GaugeFields[b], self._HiggsFields[i], self._HiggsFields[j] ) + val = diff( + self._VGauge, + self._GaugeFields[a], + self._GaugeFields[b], + self._HiggsFields[i], + self._HiggsFields[j], + ) if val != 0: - print("Curvature_Gauge_G2H2.at(" + str(a) + ").at(" + str(b) + ").at(" + str(i) + ").at(" + str(j) + ") = " + self.convertToCPP(val) + ";") + print( + "Curvature_Gauge_G2H2.at(" + + str(a) + + ").at(" + + str(b) + + ").at(" + + str(i) + + ").at(" + + str(j) + + ") = " + + self.convertToCPP(val) + + ";" + ) def printLeptons(self): for a in range(self._nLeptons): for b in range(self._nLeptons): for i in range(self._nHiggs): - val = diff(self._VLep, self._LeptonFields[a], self._LeptonFields[b], self._HiggsFields[i] ) - if(val != 0): - print("Curvature_Lepton_F2H1.at(" + str(a) + ").at(" + str(b) + ").at(" + str(i) + ") = " + self.convertToCPP(val) + ";") - + val = diff( + self._VLep, + self._LeptonFields[a], + self._LeptonFields[b], + self._HiggsFields[i], + ) + if val != 0: + print( + "Curvature_Lepton_F2H1.at(" + + str(a) + + ").at(" + + str(b) + + ").at(" + + str(i) + + ") = " + + self.convertToCPP(val) + + ";" + ) + def printQuarks(self): for a in range(self._nQuarks): for b in range(self._nQuarks): for i in range(self._nHiggs): - val = diff(self._VQuarks, self._QuarkFields[a], self._QuarkFields[b], self._HiggsFields[i]) + val = diff( + self._VQuarks, + self._QuarkFields[a], + self._QuarkFields[b], + self._HiggsFields[i], + ) if val != 0: - print("Curvature_Quark_F2H1.at(" + str(a) + ").at(" + str(b) + ").at(" + str(i) + ") = " + self.convertToCPP(val) + ";") + print( + "Curvature_Quark_F2H1.at(" + + str(a) + + ").at(" + + str(b) + + ").at(" + + str(i) + + ") = " + + self.convertToCPP(val) + + ";" + ) def printCtrInfo(self): nPar = len(self._params) @@ -297,7 +456,7 @@ def printCtrInfo(self): if lhs != rhs: nPar -= 1 - print("nPar = " + str(nPar) +";" ) + print("nPar = " + str(nPar) + ";") lenCT = len(self._dparams) + len(self._CTTadpoles) print("nParCT = " + str(lenCT) + ";") @@ -358,23 +517,23 @@ def printModelToCPP(self): print("") def printTreeSimplified(self): - vevCounter=0 + vevCounter = 0 for i in range(self._nHiggs): val = self._VEVAtFiniteTemp[i][1] - if(val != 0): + if val != 0: print("double " + self.convertToCPP(val) + " = v.at(" + str(i) + ");") - vevCounter+=1 + vevCounter += 1 VS = simplify(expand(self._VHiggs.subs(self._VEVAtFiniteTemp))) - print(self.convertToCPP(VS,"res")) + print(self.convertToCPP(VS, "res")) def printVCTSimplified(self): - vevCounter=0 + vevCounter = 0 for i in range(self._nHiggs): val = self._VEVAtFiniteTemp[i][1] - if(val != 0): + if val != 0: print("double " + self.convertToCPP(val) + " = v.at(" + str(i) + ");") - vevCounter+=1 + vevCounter += 1 VS = simplify(expand(self._VCT.subs(self._VEVAtFiniteTemp))) - print(self.convertToCPP(VS,"res")) \ No newline at end of file + print(self.convertToCPP(VS, "res")) diff --git a/tools/ModelGeneration/sympy/SM.py b/tools/ModelGeneration/sympy/SM.py index f6e47c52..85a6396c 100644 --- a/tools/ModelGeneration/sympy/SM.py +++ b/tools/ModelGeneration/sympy/SM.py @@ -8,135 +8,143 @@ # SM paramters -Cg = symbols('C_g',real=True) -Cgs = symbols('C_gs',real=True) -sigma0 = Matrix([[1,0],[0,1]]) -sigma1 = Matrix([[0,1],[1,0]]) -sigma2 = Matrix([[0,-I],[I,0]]) -sigma3 = Matrix([[1,0],[0,-1]]) -m_electron = symbols('C_MassElectron',real=True) -m_mu = symbols('C_MassMu',real=True) -m_tau = symbols('C_MassTau',real=True) -m_up = symbols('C_MassUp',real=True) -m_charm = symbols('C_MassCharm',real=True) -m_top = symbols('C_MassTop',real=True) -m_down = symbols('C_MassDown',real=True) -m_strange = symbols('C_MassStrange',real=True) -m_bottom = symbols('C_MassBottom',real=True) - +Cg = symbols("C_g", real=True) +Cgs = symbols("C_gs", real=True) +sigma0 = Matrix([[1, 0], [0, 1]]) +sigma1 = Matrix([[0, 1], [1, 0]]) +sigma2 = Matrix([[0, -I], [I, 0]]) +sigma3 = Matrix([[1, 0], [0, -1]]) +m_electron = symbols("C_MassElectron", real=True) +m_mu = symbols("C_MassMu", real=True) +m_tau = symbols("C_MassTau", real=True) +m_up = symbols("C_MassUp", real=True) +m_charm = symbols("C_MassCharm", real=True) +m_top = symbols("C_MassTop", real=True) +m_down = symbols("C_MassDown", real=True) +m_strange = symbols("C_MassStrange", real=True) +m_bottom = symbols("C_MassBottom", real=True) # CKM Matrix -Vud,Vus,Vub,Vcd,Vcs,Vcb,Vtd,Vts,Vtb = symbols('Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb') -VCKM = Matrix([[Vud,Vus,Vub],[Vcd,Vcs,Vcb],[Vtd,Vts,Vtb]]) +Vud, Vus, Vub, Vcd, Vcs, Vcb, Vtd, Vts, Vtb = symbols( + "Vud Vus Vub Vcd Vcs Vcb Vtd Vts Vtb" +) +VCKM = Matrix([[Vud, Vus, Vub], [Vcd, Vcs, Vcb], [Vtd, Vts, Vtb]]) -#parameters -msq, la = symbols('msq lambda', real=True) -params=[msq,la] +# parameters +msq, la = symbols("msq lambda", real=True) +params = [msq, la] -#CT params -dmsq, dla = symbols('dmsq dlambda', real=True) -dparams=[dmsq,dla] +# CT params +dmsq, dla = symbols("dmsq dlambda", real=True) +dparams = [dmsq, dla] -#VEVs -v = symbols('v', real=True) +# VEVs +v = symbols("v", real=True) -#Higgsfields -rho,eta,zeta,psi = symbols('rho eta zeta psi', real=True) -Higgsfields=[rho,eta,zeta,psi] -CTTadpoles = symbols('dT1:{}'.format(len(Higgsfields)+1),real=True) +# Higgsfields +rho, eta, zeta, psi = symbols("rho eta zeta psi", real=True) +Higgsfields = [rho, eta, zeta, psi] +CTTadpoles = symbols("dT1:{}".format(len(Higgsfields) + 1), real=True) -#doublets -phi = Matrix([[rho+I*eta], [zeta+I*psi]]) * 1/sqrt(2) +# doublets +phi = Matrix([[rho + I * eta], [zeta + I * psi]]) * 1 / sqrt(2) -#replacements -zeroTempVEV = [(rho,0),(eta,0),(zeta,v),(psi,0)] +# replacements +zeroTempVEV = [(rho, 0), (eta, 0), (zeta, v), (psi, 0)] finiteTempVEV = zeroTempVEV -fieldsZero = [(x,0) for x in Higgsfields] +fieldsZero = [(x, 0) for x in Higgsfields] -phiSq = simplify((Dagger(phi)*phi)[0]) -VHiggs = msq/2 * phiSq + la/factorial(4) * phiSq**2 +phiSq = simplify((Dagger(phi) * phi)[0]) +VHiggs = msq / 2 * phiSq + la / factorial(4) * phiSq**2 # Set Gauge fields -W1, W2, W3, B0 = symbols('W1 W2 W3 B0',real=True) +W1, W2, W3, B0 = symbols("W1 W2 W3 B0", real=True) -Dmu = -I*Cg/2 * (sigma1*W1 + sigma2 * W2 + sigma3*W3) -I*Cgs/2 * sigma0 * B0 -VGauge = simplify(Dagger(Dmu*phi)*(Dmu*phi))[0,0] +Dmu = ( + -I * Cg / 2 * (sigma1 * W1 + sigma2 * W2 + sigma3 * W3) - I * Cgs / 2 * sigma0 * B0 +) +VGauge = simplify(Dagger(Dmu * phi) * (Dmu * phi))[0, 0] # Generate Lepton Potentials -NuL = symbols('veL vmuL vtauL',real=True) -ER = symbols('eR muR tauR', real=True) -EL = symbols('eL muL tauL', real=True) +NuL = symbols("veL vmuL vtauL", real=True) +ER = symbols("eR muR tauR", real=True) +EL = symbols("eL muL tauL", real=True) -ye = sqrt(2)*m_electron/v -ymu = sqrt(2)*m_mu/v -ytau = sqrt(2)*m_tau/v +ye = sqrt(2) * m_electron / v +ymu = sqrt(2) * m_mu / v +ytau = sqrt(2) * m_tau / v -PiLep = Matrix([[ye,0,0],[0,ymu,0],[0,0,ytau]]) +PiLep = Matrix([[ye, 0, 0], [0, ymu, 0], [0, 0, ytau]]) VFLep = 0 for i in range(len(NuL)): for j in range(len(ER)): - VFLep += (NuL[i] * PiLep[i,j] * ER[j])*phi[0] + VFLep += (NuL[i] * PiLep[i, j] * ER[j]) * phi[0] for i in range(len(EL)): for j in range(len(ER)): - VFLep += (EL[i] * PiLep[i,j] * ER[j])*phi[1] + VFLep += (EL[i] * PiLep[i, j] * ER[j]) * phi[1] VFLep = simplify(VFLep) LepBase = NuL + ER + EL # Generate Quark Potentials -UL = symbols('uL cL tL', real=True) -DL = symbols('dL sL bL', real=True) -UR = symbols('uR cR tR', real=True) -DR = symbols('dR sR bR', real=True) +UL = symbols("uL cL tL", real=True) +DL = symbols("dL sL bL", real=True) +UR = symbols("uR cR tR", real=True) +DR = symbols("dR sR bR", real=True) QuarkBase = UL + DL + UR + DR -yb = sqrt(2)*m_bottom/v -yc = sqrt(2)*m_charm/v -yd = sqrt(2)*m_down/v -ys = sqrt(2)*m_strange/v -yt = sqrt(2)*m_top/v -yu = sqrt(2)*m_up/v +yb = sqrt(2) * m_bottom / v +yc = sqrt(2) * m_charm / v +yd = sqrt(2) * m_down / v +ys = sqrt(2) * m_strange / v +yt = sqrt(2) * m_top / v +yu = sqrt(2) * m_up / v -DownCoupling = Matrix([[yd,0,0],[0,ys,0],[0,0,yb]]) -UpCoupling = Matrix([[yu,0,0],[0,yc,0],[0,0,yt]]) +DownCoupling = Matrix([[yd, 0, 0], [0, ys, 0], [0, 0, yb]]) +UpCoupling = Matrix([[yu, 0, 0], [0, yc, 0], [0, 0, yt]]) ULVector = Matrix([[x] for x in UL]) DLVector = Matrix([[x] for x in DL]) URVector = Matrix([[x] for x in UR]) DRVector = Matrix([[x] for x in DR]) -VQuark = ULVector.transpose() * VCKM * DownCoupling * DRVector * phi[0] -VQuark+= DLVector.transpose() * DownCoupling * DRVector * phi[0] -VQuark+= ULVector.transpose() * UpCoupling * URVector * phi[1].conjugate() -VQuark+= -DLVector.transpose() * Dagger(VCKM)*UpCoupling*URVector*phi[1].conjugate() -VQuark = simplify(VQuark[0,0]) - +VQuark = ULVector.transpose() * VCKM * DownCoupling * DRVector * phi[0] +VQuark += DLVector.transpose() * DownCoupling * DRVector * phi[0] +VQuark += ULVector.transpose() * UpCoupling * URVector * phi[1].conjugate() +VQuark += ( + -DLVector.transpose() * Dagger(VCKM) * UpCoupling * URVector * phi[1].conjugate() +) +VQuark = simplify(VQuark[0, 0]) # Generate the model -toyModel = ModelGenerator.ModelGenerator(params,dparams,CTTadpoles,Higgsfields,VHiggs,zeroTempVEV,finiteTempVEV) -toyModel.setGauge([W1,W2,W3,B0],VGauge) +toyModel = ModelGenerator.ModelGenerator( + params, dparams, CTTadpoles, Higgsfields, VHiggs, zeroTempVEV, finiteTempVEV +) +toyModel.setGauge([W1, W2, W3, B0], VGauge) toyModel.setLepton(LepBase, VFLep) toyModel.setQuark(QuarkBase, VQuark) - - - - parser = argparse.ArgumentParser() -parser.add_argument('-s','--show',choices=['ct','tensor','treeSimpl','CTSimpl'],required=True,help='The part of the model to be printed') +parser.add_argument( + "-s", + "--show", + choices=["ct", "tensor", "treeSimpl", "CTSimpl"], + required=True, + help="The part of the model to be printed", +) if __name__ == "__main__": args = parser.parse_args() method = args.show - printCT = method == 'ct' - printTensors = method == 'tensor' + printCT = method == "ct" + printTensors = method == "tensor" if printCT: print("//Begin CT Calculation") @@ -150,8 +158,8 @@ if printTensors: toyModel.printModelToCPP() - if method == 'treeSimpl': + if method == "treeSimpl": toyModel.printTreeSimplified() - - if method == 'CTSimpl': - toyModel.printVCTSimplified() \ No newline at end of file + + if method == "CTSimpl": + toyModel.printVCTSimplified() From f1a8e030bec02f741969a201109ad68aad3e8f71 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sat, 1 Jun 2024 21:56:12 +0200 Subject: [PATCH 02/69] Move cmaes and nlopt as seperate libraries --- CMakeLists.txt | 12 +++++-- src/CMakeLists.txt | 19 +++++++++++ src/bounce_solution/CMakeLists.txt | 11 +++++-- src/gravitational_waves/CMakeLists.txt | 14 ++++++-- src/minimizer/CMakeLists.txt | 43 ++++++++++++------------- src/minimizer/LibCMAES/CMakeLists.txt | 29 +++++++++++++++++ src/minimizer/LibNLOPT/CMakeLists.txt | 31 ++++++++++++++++++ src/utility/CMakeLists.txt | 12 +++++-- src/utility/asciiplotter/CMakeLists.txt | 10 +++++- test_package/CMakeLists.txt | 2 +- test_package/src/example.cpp | 11 ++++++- 11 files changed, 160 insertions(+), 34 deletions(-) create mode 100644 src/minimizer/LibCMAES/CMakeLists.txt create mode 100644 src/minimizer/LibNLOPT/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b5e29405..d46c2aed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,7 @@ if(NOT libcmaes_FOUND AND NOT NLopt_FOUND) message(FATAL_ERROR "You need at least libcmaes or NLopt.") endif() -configure_file(include/BSMPT/config.h.in include/BSMPT/config.h) + # -------------------- Coverage # -------------------------------------------------- @@ -161,6 +161,8 @@ find_lto(CXX) add_subdirectory(src) add_subdirectory(standalone) +# ----- installation + # -------------------------- export as cmake package -------------------------- if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) include(CMakePackageConfigHelpers) @@ -169,7 +171,13 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) VERSION ${PACKAGE_VERSION} COMPATIBILITY AnyNewerVersion) - set(ExportList Models Minimizer ThermalFunctions Utility Spline ASCIIPlotter) + set(ExportList Models Minimizer ThermalFunctions Utility Spline ASCIIPlotter BSMPT_Config) + if(libcmaes_FOUND) + list(APPEND ExportList Minimizer_CMAES) + endif() + if(NLopt_FOUND) + list(APPEND ExportList Minimizer_NLOPT) + endif() if(BSMPTCompileBaryo) set(ExportList ${ExportList} Baryo LibWallThickness Kfactors) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 259d250a..d23bae9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,25 @@ # # SPDX-License-Identifier: GPL-3.0-or-later + +configure_file(${BSMPT_SOURCE_DIR}/include/BSMPT/config.h.in ${BSMPT_BINARY_DIR}/include/BSMPT/config.h) +add_library(BSMPT_Config INTERFACE) +set(header_path ${BSMPT_BINARY_DIR}/include/BSMPT) +target_include_directories(BSMPT_Config INTERFACE + + + + ) +set(header ${header_path}/config.h) +set_property(TARGET BSMPT_Config PROPERTY PUBLIC_HEADER ${header}) + + +install( + TARGETS BSMPT_Config + PUBLIC_HEADER DESTINATION include/BSMPT +) + + add_subdirectory(minimizer) add_subdirectory(models) if(BSMPTCompileBaryo) diff --git a/src/bounce_solution/CMakeLists.txt b/src/bounce_solution/CMakeLists.txt index ed43c8f0..f72db0ad 100644 --- a/src/bounce_solution/CMakeLists.txt +++ b/src/bounce_solution/CMakeLists.txt @@ -2,8 +2,8 @@ # João Viana # # SPDX-License-Identifier: GPL-3.0-or-later - -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/bounce_solution") +set(suffix "include/BSMPT/bounce_solution") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/bounce_solution.h ${header_path}/action_calculation.h) set(src bounce_solution.cpp action_calculation.cpp) @@ -13,3 +13,10 @@ target_link_libraries(BounceSolution PUBLIC Eigen3::Eigen GSL::gsl Minimizer Utility MinimumTracer) target_include_directories(BounceSolution PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(BounceSolution PUBLIC cxx_std_14) + +set_property(TARGET BounceSolution PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS BounceSolution + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/gravitational_waves/CMakeLists.txt b/src/gravitational_waves/CMakeLists.txt index 403b80a9..9019ad67 100644 --- a/src/gravitational_waves/CMakeLists.txt +++ b/src/gravitational_waves/CMakeLists.txt @@ -3,13 +3,21 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/gravitational_waves") +set(suffix "include/BSMPT/gravitational_waves") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/gw.h) set(src gw.cpp) -add_library(GW ${header} ${src}) +add_library(GW STATIC ${header} ${src}) target_link_libraries(GW PUBLIC Eigen3::Eigen GSL::gsl Minimizer Utility BounceSolution) target_include_directories(GW PUBLIC ${BSMPT_SOURCE_DIR}/include) -target_compile_features(GW PUBLIC cxx_std_14) +target_compile_features(GW PUBLIC cxx_std_17) + +set_property(TARGET GW PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS GW + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/minimizer/CMakeLists.txt b/src/minimizer/CMakeLists.txt index 2d3712b1..340b37fc 100644 --- a/src/minimizer/CMakeLists.txt +++ b/src/minimizer/CMakeLists.txt @@ -3,42 +3,41 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/minimizer") +set(suffix "include/BSMPT/minimizer") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/Minimizer.h ${header_path}/MinimizePlane.h ${header_path}/MinimizeGSL.h) -set(src MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp) -if(libcmaes_FOUND) - set(header ${header} ${header_path}/LibCMAES/MinimizeLibCMAES.h) - set(src ${src} LibCMAES/MinimizeLibCMAES.cpp) -endif() - -if(NLopt_FOUND) - set(header ${header} ${header_path}/LibNLOPT/MinimizeNLOPT.h) - set(src ${src} LibNLOPT/MinimizeNLOPT.cpp) -endif() - -add_library(Minimizer ${header} ${src}) +add_library(Minimizer STATIC) target_link_libraries(Minimizer PUBLIC Eigen3::Eigen GSL::gsl Threads::Threads Utility Models) +target_sources(Minimizer PRIVATE MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp PUBLIC ${header}) + + if(libcmaes_FOUND) - target_link_libraries(Minimizer PRIVATE libcmaes::cmaes) - if(OpenMP_FOUND) - target_link_libraries(Minimizer PRIVATE OpenMP::OpenMP_CXX) - endif() + add_subdirectory(LibCMAES) + target_link_libraries(Minimizer PUBLIC Minimizer_CMAES) endif() if(NLopt_FOUND) - if(TARGET NLopt::nlopt) - target_link_libraries(Minimizer PUBLIC NLopt::nlopt) - else() - target_link_libraries(Minimizer PUBLIC NLopt::nlopt_cxx) - endif() + add_subdirectory(LibNLOPT) + target_link_libraries(Minimizer PUBLIC Minimizer_NLOPT) endif() + + + + target_include_directories(Minimizer PUBLIC ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) target_include_directories(Minimizer PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(Minimizer PUBLIC cxx_std_17) + +set_property(TARGET Minimizer PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS Minimizer + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt new file mode 100644 index 00000000..06335ef3 --- /dev/null +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas +# Müller +# +# SPDX-License-Identifier: GPL-3.0-or-later + +set(suffix "include/BSMPT/minimizer/LibCMAES") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") +set(header ${header_path}/MinimizeLibCMAES.h) + +add_library(Minimizer_CMAES INTERFACE) +target_sources(Minimizer_CMAES INTERFACE MinimizeLibCMAES.cpp ${header}) +target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) + +target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) +if(OpenMP_FOUND) +target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) +endif() + +target_include_directories(Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include + ${BSMPT_BINARY_DIR}/include) +target_include_directories(Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include) +target_compile_features(Minimizer_CMAES INTERFACE cxx_std_17) + +set_property(TARGET Minimizer_CMAES PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS Minimizer_CMAES + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/minimizer/LibNLOPT/CMakeLists.txt b/src/minimizer/LibNLOPT/CMakeLists.txt new file mode 100644 index 00000000..4373311c --- /dev/null +++ b/src/minimizer/LibNLOPT/CMakeLists.txt @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas +# Müller +# +# SPDX-License-Identifier: GPL-3.0-or-later + +set(suffix "include/BSMPT/minimizer/LibNLOPT") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") +set(header ${header_path}/MinimizeNLOPT.h) + +set(src MinimizeNLOPT.cpp) + +add_library(Minimizer_NLOPT STATIC ${header} ${src}) +target_link_libraries(Minimizer_NLOPT PUBLIC Minimizer) + + if(TARGET NLopt::nlopt) + target_link_libraries(Minimizer_NLOPT PUBLIC NLopt::nlopt) + else() + target_link_libraries(Minimizer_NLOPT PUBLIC NLopt::nlopt_cxx) + endif() + +target_include_directories(Minimizer_NLOPT PUBLIC ${BSMPT_SOURCE_DIR}/include + ${BSMPT_BINARY_DIR}/include) +target_include_directories(Minimizer_NLOPT PUBLIC ${BSMPT_SOURCE_DIR}/include) +target_compile_features(Minimizer_NLOPT PUBLIC cxx_std_17) + +set_property(TARGET Minimizer_NLOPT PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS Minimizer_NLOPT + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/utility/CMakeLists.txt b/src/utility/CMakeLists.txt index 43b1036b..a2ae3677 100644 --- a/src/utility/CMakeLists.txt +++ b/src/utility/CMakeLists.txt @@ -3,7 +3,8 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/utility") +set(suffix "include/BSMPT/utility") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/utility.h ${header_path}/Logger.h ${header_path}/parser.h ${header_path}/const_velocity_spline.h @@ -22,4 +23,11 @@ if(nlohmann_json_FOUND) target_link_libraries(Utility PRIVATE nlohmann_json::nlohmann_json) endif() -target_link_libraries(Utility PUBLIC ASCIIPlotter Spline GSL::gsl) +target_link_libraries(Utility PUBLIC ASCIIPlotter Spline GSL::gsl BSMPT_Config) + +set_property(TARGET Utility PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS Utility + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/utility/asciiplotter/CMakeLists.txt b/src/utility/asciiplotter/CMakeLists.txt index 9c295266..67686d76 100644 --- a/src/utility/asciiplotter/CMakeLists.txt +++ b/src/utility/asciiplotter/CMakeLists.txt @@ -3,10 +3,12 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/utility/asciiplotter") +set(suffix "include/BSMPT/utility/asciiplotter") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/asciiplotter.h) set(src asciiplotter.cpp) add_library(ASCIIPlotter ${header} ${src}) +set_property(TARGET ASCIIPlotter PROPERTY PUBLIC_HEADER ${header}) target_include_directories(ASCIIPlotter PUBLIC ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) if(Boost_FOUND) @@ -17,3 +19,9 @@ target_compile_features(ASCIIPlotter PUBLIC cxx_std_17) if(nlohmann_json_FOUND) target_link_libraries(ASCIIPlotter PRIVATE nlohmann_json::nlohmann_json) endif() + +install( + TARGETS Utility + PUBLIC_HEADER DESTINATION ${suffix} +) + diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 53e37878..2f633589 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries(example bsmpt::utility) \ No newline at end of file +target_link_libraries(example bsmpt::bsmpt) \ No newline at end of file diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index 0d257495..ecc8de2d 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -1,4 +1,13 @@ -#include "hello.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include int main() { hello(); From b09dce5942b06818c60edc2256882892b23f718f Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sat, 1 Jun 2024 22:01:07 +0200 Subject: [PATCH 03/69] Add install paths --- src/ThermalFunctions/CMakeLists.txt | 11 ++++++++++- src/minimum_tracer/CMakeLists.txt | 15 ++++++++++++--- src/models/CMakeLists.txt | 13 +++++++++++-- src/transition_tracer/CMakeLists.txt | 12 +++++++++++- src/utility/spline/CMakeLists.txt | 11 ++++++++++- 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/ThermalFunctions/CMakeLists.txt b/src/ThermalFunctions/CMakeLists.txt index 20022f62..deecc0ef 100644 --- a/src/ThermalFunctions/CMakeLists.txt +++ b/src/ThermalFunctions/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/ThermalFunctions") +set(suffix "include/BSMPT/ThermalFunctions") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/ThermalFunctions.h ${header_path}/NegativeBosonSpline.h ${header_path}/thermalcoefficientcalculator.h) @@ -15,3 +17,10 @@ add_library(ThermalFunctions ${header} ${src}) target_link_libraries(ThermalFunctions PUBLIC GSL::gsl Utility) target_include_directories(ThermalFunctions PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(ThermalFunctions PUBLIC cxx_std_17) + +set_property(TARGET ThermalFunctions PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS ThermalFunctions + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/minimum_tracer/CMakeLists.txt b/src/minimum_tracer/CMakeLists.txt index fa45ce75..dc3d9ffa 100644 --- a/src/minimum_tracer/CMakeLists.txt +++ b/src/minimum_tracer/CMakeLists.txt @@ -3,13 +3,22 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/minimum_tracer") +set(suffix "include/BSMPT/minimum_tracer") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/minimum_tracer.h) set(src minimum_tracer.cpp) -add_library(MinimumTracer ${header} ${src}) +add_library(MinimumTracer STATIC ${header} ${src}) target_link_libraries(MinimumTracer PUBLIC Eigen3::Eigen GSL::gsl Minimizer Utility) + target_include_directories(MinimumTracer PUBLIC ${BSMPT_SOURCE_DIR}/include) -target_compile_features(MinimumTracer PUBLIC cxx_std_14) +target_compile_features(MinimumTracer PUBLIC cxx_std_17) + +set_property(TARGET MinimumTracer PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS MinimumTracer + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/models/CMakeLists.txt b/src/models/CMakeLists.txt index 26ab76f8..a84e6a04 100644 --- a/src/models/CMakeLists.txt +++ b/src/models/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/models") +set(suffix "include/BSMPT/models") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/SMparam.h ${header_path}/ModelTestfunctions.h @@ -33,7 +35,7 @@ set(src # Here you can add your new model ClassTemplate.cpp) -add_library(Models ${header} ${src}) +add_library(Models STATIC ${header} ${src}) target_link_libraries(Models PUBLIC GSL::gsl Eigen3::Eigen Minimizer ThermalFunctions Utility) target_include_directories(Models PUBLIC ${BSMPT_SOURCE_DIR}/include) @@ -41,3 +43,10 @@ target_compile_features(Models PUBLIC cxx_std_17) # Include code-coverage settings: target_link_libraries(Models PUBLIC # coverage_config) + +set_property(TARGET Models PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS Models + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/transition_tracer/CMakeLists.txt b/src/transition_tracer/CMakeLists.txt index 34e0ce89..e886b056 100644 --- a/src/transition_tracer/CMakeLists.txt +++ b/src/transition_tracer/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/transition_tracer") +set(suffix "include/BSMPT/transition_tracer") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/transition_tracer.h) set(src transition_tracer.cpp) @@ -12,3 +14,11 @@ add_library(TransitionTracer ${header} ${src}) target_link_libraries(TransitionTracer PUBLIC MinimumTracer BounceSolution GW) target_include_directories(TransitionTracer PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(TransitionTracer PUBLIC cxx_std_14) + + +set_property(TARGET TransitionTracer PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS TransitionTracer + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file diff --git a/src/utility/spline/CMakeLists.txt b/src/utility/spline/CMakeLists.txt index 1b630dc8..dc07c296 100644 --- a/src/utility/spline/CMakeLists.txt +++ b/src/utility/spline/CMakeLists.txt @@ -3,7 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -set(header_path "${BSMPT_SOURCE_DIR}/include/BSMPT/utility/spline") +set(suffix "include/BSMPT/utility/spline") +set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") + set(header ${header_path}/spline.h) set(src spline.cpp) add_library(Spline ${header} ${src}) @@ -19,3 +21,10 @@ if(nlohmann_json_FOUND) endif() target_compile_definitions(Spline PRIVATE _USE_MATH_DEFINES) + +set_property(TARGET Spline PROPERTY PUBLIC_HEADER ${header}) + +install( + TARGETS Spline + PUBLIC_HEADER DESTINATION ${suffix} +) \ No newline at end of file From 973f261e8e1685d51a52c15fc2ac820d354cb30d Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sat, 1 Jun 2024 22:52:45 +0200 Subject: [PATCH 04/69] Start with components --- Setup.py | 1 + conanfile.py | 22 +++++++++++++++++----- src/utility/asciiplotter/CMakeLists.txt | 2 +- test_package/src/example.cpp | 11 +++++------ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Setup.py b/Setup.py index 927beffc..156509f8 100644 --- a/Setup.py +++ b/Setup.py @@ -200,6 +200,7 @@ def create(): for conf in config_settings: cmd += ["-c", conf] + subprocess.check_call(cmd) diff --git a/conanfile.py b/conanfile.py index 8f01036a..f02214b4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,7 +15,14 @@ class BSMPT(ConanFile): name = "bsmpt" version = "3.0.2" - exports_sources = "CMakeLists.txt", "src/*", "include/*", "tools/*", "tests/*" , "standalone/*" + exports_sources = ( + "CMakeLists.txt", + "src/*", + "include/*", + "tools/*", + "tests/*", + "standalone/*", + ) options = { "EnableTests": [True, False], # enables the unit tests @@ -92,13 +99,10 @@ def validate(self): tools.build.check_min_cppstd(self, "17") - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - - def build(self): cmake = CMake(self) cmake.configure() @@ -108,4 +112,12 @@ def package(self): cmake = CMake(self) cmake.install() - + def package_info(self): + self.cpp_info.components["BounceSolution"].libs = ["BounceSolution"] + self.cpp_info.components["BounceSolution"].requires = [ + "eigen::eigen", + "gsl::gsl", + #"Minimizer", + #"Utility", + #"MinimumTracer", + ] diff --git a/src/utility/asciiplotter/CMakeLists.txt b/src/utility/asciiplotter/CMakeLists.txt index 67686d76..3039943a 100644 --- a/src/utility/asciiplotter/CMakeLists.txt +++ b/src/utility/asciiplotter/CMakeLists.txt @@ -21,7 +21,7 @@ if(nlohmann_json_FOUND) endif() install( - TARGETS Utility + TARGETS ASCIIPlotter PUBLIC_HEADER DESTINATION ${suffix} ) diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index ecc8de2d..b9e5c4b3 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -1,14 +1,13 @@ -#include -#include -#include +//#include +//#include +//#include #include -#include +/*#include #include #include #include #include -#include +#include */ int main() { - hello(); } From 8513912ac9a5fe2b05ebf31e22e07d9a98906356 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 13:34:54 +0200 Subject: [PATCH 05/69] create conan worklfow to test test_package --- .github/workflows/conan.yml | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/conan.yml diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml new file mode 100644 index 00000000..2b7f11e1 --- /dev/null +++ b/.github/workflows/conan.yml @@ -0,0 +1,39 @@ +name: Run conan + +on: + push: + branches: + - master + - main + - feature/create-conan-package + pull_request: + branches: + - master + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + +jobs: + conan: + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{matrix.os}} + if: "!contains(github.event.head_commit.message, 'skip-ci')" + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + - name: Install conan + run: pip install conan>2 + - run: conan profile detect + - run: conan create . --build=missing From c8212511402a2bbd2b37babe38360859077a5f17 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 13:34:55 +0200 Subject: [PATCH 06/69] create conan workflow --- conanfile.py | 96 +++++++++++++++++++++++++++++++++++-- test_package/CMakeLists.txt | 2 +- 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index f02214b4..27acb498 100644 --- a/conanfile.py +++ b/conanfile.py @@ -113,11 +113,101 @@ def package(self): cmake.install() def package_info(self): + + self.cpp_info.components["ASCIIPlotter"].libs = ["ASCIIPlotter"] + self.cpp_info.components["ASCIIPlotter"].requires = [ + "nlohmann_json::nlohmann_json", + ] + + if self.options.CompileBaryo: + self.cpp_info.components["ASCIIPlotter"].requires.append( + "boost::boost", + ) + + self.cpp_info.components["Spline"].libs = ["Spline"] + self.cpp_info.components["Spline"].requires = [ + "nlohmann_json::nlohmann_json", + ] + + if self.options.CompileBaryo: + self.cpp_info.components["Spline"].requires.append( + "boost::boost", + ) + + self.cpp_info.components["Utility"].libs = ["Utility"] + self.cpp_info.components["Utility"].requires = [ + "gsl::gsl", + "nlohmann_json::nlohmann_json", + "ASCIIPlotter", + "Spline", + ] + + if self.options.CompileBaryo: + self.cpp_info.components["Utility"].requires.append( + "boost::boost", + ) + self.cpp_info.components["BounceSolution"].libs = ["BounceSolution"] self.cpp_info.components["BounceSolution"].requires = [ "eigen::eigen", "gsl::gsl", - #"Minimizer", - #"Utility", - #"MinimumTracer", + "Minimizer", + "Utility", + "MinimumTracer", + ] + + self.cpp_info.components["GW"].libs = ["GW"] + self.cpp_info.components["GW"].requires = [ + "eigen::eigen", + "gsl::gsl", + "Minimizer", + "Utility", + "BounceSolution", + ] + + self.cpp_info.components["Minimizer"].libs = ["Minimizer"] + self.cpp_info.components["Minimizer"].requires = [ + "eigen::eigen", + "gsl::gsl", + "Threads::Threads", + "Utility", + "Models", + # "Minimizer_CMAES" + ] + + if self.options.UseNLopt: + + self.cpp_info.components["Minimizer_NLOPT"].libs = ["Minimizer_NLOPT"] + self.cpp_info.components["Minimizer_NLOPT"].requires = [ + "nlopt::nlopt", + "Minimizer", + ] + + self.cpp_info.components["Minimizer"].requires.append("Minimizer_NLOPT") + + self.cpp_info.components["MinimumTracer"].libs = ["MinimumTracer"] + self.cpp_info.components["MinimumTracer"].requires = [ + "eigen::eigen", + "gsl::gsl", + "Minimizer", + "Utility", + ] + + self.cpp_info.components["Models"].libs = ["Models"] + self.cpp_info.components["Models"].requires = [ + "gsl::gsl", + "eigen::eigen", + "Minimizer", + "ThermalFunctions", + "Utility", + ] + + self.cpp_info.components["ThermalFunctions"].libs = ["ThermalFunctions"] + self.cpp_info.components["ThermalFunctions"].requires = ["gsl::gsl", "Utility"] + + self.cpp_info.components["TransitionTracer"].libs = ["TransitionTracer"] + self.cpp_info.components["TransitionTracer"].requires = [ + "BounceSolution", + "MinimumTracer", + "GW", ] diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 2f633589..3e5af26a 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries(example bsmpt::bsmpt) \ No newline at end of file +target_link_libraries(example bsmpt::Utility) \ No newline at end of file From a3f73334fdde3a1c3ba2ef7a5c5c557dcdad0fd4 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 13:38:17 +0200 Subject: [PATCH 07/69] remove fpic --- conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index 27acb498..b9e80421 100644 --- a/conanfile.py +++ b/conanfile.py @@ -100,8 +100,9 @@ def validate(self): tools.build.check_min_cppstd(self, "17") def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + pass + #if self.settings.os == "Windows": + # del self.options.fPIC def build(self): cmake = CMake(self) From 6e40c117726d4ca25cabdb09c1ad53bd0797c17e Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 13:43:48 +0200 Subject: [PATCH 08/69] use script --- .github/workflows/conan.yml | 3 +-- Setup.py | 11 ++++++++--- conanfile.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 2b7f11e1..4e415032 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -35,5 +35,4 @@ jobs: architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - name: Install conan run: pip install conan>2 - - run: conan profile detect - - run: conan create . --build=missing + - run: python3 Setup.py --create --build=missing diff --git a/Setup.py b/Setup.py index 156509f8..433e9e69 100644 --- a/Setup.py +++ b/Setup.py @@ -188,7 +188,7 @@ def conan_install_all( ) -def create(): +def create(build_missing=False): config_settings = [ "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" @@ -200,6 +200,9 @@ def create(): for conf in config_settings: cmd += ["-c", conf] + if build_missing: + cmd += ["--build=missing"] + subprocess.check_call(cmd) @@ -251,11 +254,13 @@ def __str__(self): opts = parser.parse_args() + setup_profiles() + if opts.create: - create() + create(build_missing=opts.build_missing,) else: - setup_profiles() + conan_install_all( opts.mode, opts.options if opts.options is not None else [], diff --git a/conanfile.py b/conanfile.py index b9e80421..c35e7dc0 100644 --- a/conanfile.py +++ b/conanfile.py @@ -170,7 +170,7 @@ def package_info(self): self.cpp_info.components["Minimizer"].requires = [ "eigen::eigen", "gsl::gsl", - "Threads::Threads", + #"Threads::Threads", "Utility", "Models", # "Minimizer_CMAES" From 41ae8a63bb9254f37439be3238deb855ddc89911 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 2 Jun 2024 13:52:09 +0200 Subject: [PATCH 09/69] Update conan.yml --- .github/workflows/conan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 4e415032..66dc33ac 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -35,4 +35,4 @@ jobs: architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - name: Install conan run: pip install conan>2 - - run: python3 Setup.py --create --build=missing + - run: python3 Setup.py --create --build-missing From fc52a6773b16f45d0c463df215a33268858691f8 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 14:00:15 +0200 Subject: [PATCH 10/69] change libnlopt to interface --- conanfile.py | 5 +---- src/minimizer/LibNLOPT/CMakeLists.txt | 14 +++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/conanfile.py b/conanfile.py index c35e7dc0..ee3c7321 100644 --- a/conanfile.py +++ b/conanfile.py @@ -178,13 +178,10 @@ def package_info(self): if self.options.UseNLopt: - self.cpp_info.components["Minimizer_NLOPT"].libs = ["Minimizer_NLOPT"] - self.cpp_info.components["Minimizer_NLOPT"].requires = [ + self.cpp_info.components["Minimizer"].requires = [ "nlopt::nlopt", - "Minimizer", ] - self.cpp_info.components["Minimizer"].requires.append("Minimizer_NLOPT") self.cpp_info.components["MinimumTracer"].libs = ["MinimumTracer"] self.cpp_info.components["MinimumTracer"].requires = [ diff --git a/src/minimizer/LibNLOPT/CMakeLists.txt b/src/minimizer/LibNLOPT/CMakeLists.txt index 4373311c..ee9423fe 100644 --- a/src/minimizer/LibNLOPT/CMakeLists.txt +++ b/src/minimizer/LibNLOPT/CMakeLists.txt @@ -9,19 +9,19 @@ set(header ${header_path}/MinimizeNLOPT.h) set(src MinimizeNLOPT.cpp) -add_library(Minimizer_NLOPT STATIC ${header} ${src}) -target_link_libraries(Minimizer_NLOPT PUBLIC Minimizer) +add_library(Minimizer_NLOPT INTERFACE ${header} ${src}) +target_link_libraries(Minimizer_NLOPT INTERFACE Minimizer) if(TARGET NLopt::nlopt) - target_link_libraries(Minimizer_NLOPT PUBLIC NLopt::nlopt) + target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt) else() - target_link_libraries(Minimizer_NLOPT PUBLIC NLopt::nlopt_cxx) + target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt_cxx) endif() -target_include_directories(Minimizer_NLOPT PUBLIC ${BSMPT_SOURCE_DIR}/include +target_include_directories(Minimizer_NLOPT INTERFACE ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) -target_include_directories(Minimizer_NLOPT PUBLIC ${BSMPT_SOURCE_DIR}/include) -target_compile_features(Minimizer_NLOPT PUBLIC cxx_std_17) +target_include_directories(Minimizer_NLOPT INTERFACE ${BSMPT_SOURCE_DIR}/include) +target_compile_features(Minimizer_NLOPT INTERFACE cxx_std_17) set_property(TARGET Minimizer_NLOPT PROPERTY PUBLIC_HEADER ${header}) From 7247f018641f2e4f3827c9a8c92733ec3b27aa86 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 14:19:29 +0200 Subject: [PATCH 11/69] fix build --- src/minimizer/CMakeLists.txt | 2 +- src/minimizer/LibNLOPT/CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/minimizer/CMakeLists.txt b/src/minimizer/CMakeLists.txt index 340b37fc..ab2af286 100644 --- a/src/minimizer/CMakeLists.txt +++ b/src/minimizer/CMakeLists.txt @@ -12,7 +12,7 @@ set(header ${header_path}/Minimizer.h ${header_path}/MinimizePlane.h add_library(Minimizer STATIC) target_link_libraries(Minimizer PUBLIC Eigen3::Eigen GSL::gsl Threads::Threads Utility Models) -target_sources(Minimizer PRIVATE MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp PUBLIC ${header}) +target_sources(Minimizer PUBLIC MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp PUBLIC ${header}) diff --git a/src/minimizer/LibNLOPT/CMakeLists.txt b/src/minimizer/LibNLOPT/CMakeLists.txt index ee9423fe..615d4bc7 100644 --- a/src/minimizer/LibNLOPT/CMakeLists.txt +++ b/src/minimizer/LibNLOPT/CMakeLists.txt @@ -9,7 +9,8 @@ set(header ${header_path}/MinimizeNLOPT.h) set(src MinimizeNLOPT.cpp) -add_library(Minimizer_NLOPT INTERFACE ${header} ${src}) +add_library(Minimizer_NLOPT INTERFACE) +target_sources(Minimizer_NLOPT INTERFACE ${header} ${src}) target_link_libraries(Minimizer_NLOPT INTERFACE Minimizer) if(TARGET NLopt::nlopt) From 14996ee2b5e23930fcae9bed91b5377db52940fd Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 14:28:37 +0200 Subject: [PATCH 12/69] set requirements transitive --- conanfile.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/conanfile.py b/conanfile.py index ee3c7321..9e31d242 100644 --- a/conanfile.py +++ b/conanfile.py @@ -50,15 +50,15 @@ class BSMPT(ConanFile): } def requirements(self): - self.requires("eigen/3.4.0") - self.requires("gsl/2.7.1") - self.requires("nlohmann_json/3.11.3") + self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) + self.requires("gsl/2.7.1", transitive_headers=True, transitive_libs=True) + self.requires("nlohmann_json/3.11.3", transitive_headers=True) if self.options.CompileBaryo: - self.requires("boost/1.84.0") + self.requires("boost/1.84.0", transitive_headers=True, transitive_libs=True) if self.options.UseNLopt: - self.requires("nlopt/2.7.1") + self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) def build_requirements(self): self.tool_requires("cmake/3.29.0") @@ -101,7 +101,7 @@ def validate(self): def config_options(self): pass - #if self.settings.os == "Windows": + # if self.settings.os == "Windows": # del self.options.fPIC def build(self): @@ -170,7 +170,7 @@ def package_info(self): self.cpp_info.components["Minimizer"].requires = [ "eigen::eigen", "gsl::gsl", - #"Threads::Threads", + # "Threads::Threads", "Utility", "Models", # "Minimizer_CMAES" @@ -182,7 +182,6 @@ def package_info(self): "nlopt::nlopt", ] - self.cpp_info.components["MinimumTracer"].libs = ["MinimumTracer"] self.cpp_info.components["MinimumTracer"].requires = [ "eigen::eigen", From 08868572149036c75463f0fc793999e4e5fdb977 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 14:39:38 +0200 Subject: [PATCH 13/69] turn off options for quicker compile time for testing --- .github/workflows/conan.yml | 2 +- CMakeLists.txt | 1 + conanfile.py | 9 ++++++--- src/CMakeLists.txt | 4 ++++ standalone/CMakeLists.txt | 5 +++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 66dc33ac..d3adee00 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -21,7 +21,7 @@ jobs: conan: strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-latest] + os: [ ubuntu-latest] runs-on: ${{matrix.os}} if: "!contains(github.event.head_commit.message, 'skip-ci')" diff --git a/CMakeLists.txt b/CMakeLists.txt index d46c2aed..a0498f5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ option(MakeAdditionalTesting "Build the executables used for further testing" option(BSMPTCompileBaryo "Compile Baryogenesis" OFF) option(EnableCoverage "Enable code coverage" OFF) option(BSMPTUseVectorization "Disable vectorization" ON) +option(BSMPTBuildExecutables "Build the executables" ON) set(BSMPT_IS_TOPLEVEL NO) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) diff --git a/conanfile.py b/conanfile.py index 9e31d242..56f6e43b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -37,16 +37,18 @@ class BSMPT(ConanFile): False, ], # compile the electroweak baryogenesis for the C2HDM "EnableCoverage": [True, False], # enable code coverage - "UseVectorization": [True, False], # use vectorization for the build + "UseVectorization": [True, False], # use vectorization for the build, + "BuildExecutables": [True,False] } default_options = { - "EnableTests": True, - "UseLibCMAES": True, + "EnableTests": False, + "UseLibCMAES": False, "UseNLopt": True, "MakeAdditionalTesting": False, "CompileBaryo": False, "EnableCoverage": False, "UseVectorization": True, + "BuildExecutables": False } def requirements(self): @@ -85,6 +87,7 @@ def generate(self): tc.variables["BSMPTCompileBaryo"] = self.options.CompileBaryo tc.variables["EnableCoverage"] = self.options.EnableCoverage tc.variables["BSMPTUseVectorization"] = self.options.UseVectorization + tc.variables["BSMPTBuildExecutables"] = self.options.BuildExecutables tc.generate() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d23bae9b..a036b1e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,6 +44,8 @@ add_subdirectory(utility/spline) # ==============================EXE====================================== +if(BSMPTBuildExecutables) + add_executable(BSMPT prog/BSMPT.cpp) target_link_libraries(BSMPT Minimizer Models Utility) target_compile_features(BSMPT PUBLIC cxx_std_17) @@ -131,3 +133,5 @@ if(MakeAdditionalTesting) endif(BSMPTCompileBaryo) endif(MakeAdditionalTesting) + +endif(BSMPTBuildExecutables) \ No newline at end of file diff --git a/standalone/CMakeLists.txt b/standalone/CMakeLists.txt index 3f787f0b..1f98cc9c 100644 --- a/standalone/CMakeLists.txt +++ b/standalone/CMakeLists.txt @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +if(BSMPTBuildExecutables) + set(STANDALONE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) file(GLOB SOURCE_FILES "*.cpp" CONFIURE_DEPENDS) @@ -27,3 +29,6 @@ foreach(file_path ${SOURCE_FILES}) target_compile_features("${filename}" PUBLIC cxx_std_14) endforeach() + + +endif(BSMPTBuildExecutables) \ No newline at end of file From 83b99388fc3f61f266bbfb13d258a284b1a710c5 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 21:43:56 +0200 Subject: [PATCH 14/69] add cxx11 flag, move os overload for modelid to models --- CMakeLists.txt | 5 ++++- conanfile.py | 23 ++++++++++++++++++++++- include/BSMPT/models/IncludeAllModels.h | 6 ++++++ include/BSMPT/utility/utility.h | 10 +--------- src/models/IncludeAllModels.cpp | 16 ++++++++++++++++ src/utility/utility.cpp | 12 ------------ test_package/CMakeLists.txt | 2 +- test_package/src/example.cpp | 7 ++++--- tools/cmake/CompilerOptions.cmake | 4 ++++ 9 files changed, 58 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0498f5e..77829033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,10 @@ # SPDX-License-Identifier: GPL-3.0-or-later cmake_minimum_required(VERSION 3.23) +set(BSMPT_VERSION 3.0.2) project( BSMPT - VERSION 3.0.2 + VERSION ${BSMPT_VERSION} LANGUAGES C CXX DESCRIPTION "BSMPT - Beyond the Standard Model Phase Transitions : A C++ package for the computation of the EWPT in BSM models" @@ -159,6 +160,8 @@ endif(EnableCoverage) find_lto(CXX) + + add_subdirectory(src) add_subdirectory(standalone) diff --git a/conanfile.py b/conanfile.py index 56f6e43b..5668d0c7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -4,6 +4,7 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout from conan.tools.files import load, update_conandata from conan.tools.scm import Git +import os, re required_conan_version = ">=2.0.0 <3" @@ -13,7 +14,7 @@ class BSMPT(ConanFile): generators = "CMakeDeps" name = "bsmpt" - version = "3.0.2" + exports_sources = ( "CMakeLists.txt", @@ -74,6 +75,26 @@ def system_requirements(self): apt = Apt(self) apt.install(["lcov"], update=True, check=True) + def set_version(self): + content = load(self, os.path.join(self.recipe_folder, "CMakeLists.txt")) + value = re.search(r"set\(BSMPT_VERSION (.*)\)", content) + extracted_version = value.group(1).strip() + + is_git_tag = False + git = Git(self, folder=self.recipe_folder) + try: + git.run("describe --exact-match --tags") + is_git_tag = True + except Exception: + is_git_tag = False + + if is_git_tag: + self.version = extracted_version + else: + # if not tag -> pre-release version + commit_hash = git.get_commit()[:8] + self.version = f"{extracted_version}.{commit_hash}" + def layout(self): cmake_layout(self) diff --git a/include/BSMPT/models/IncludeAllModels.h b/include/BSMPT/models/IncludeAllModels.h index 3b72adf1..c889bfc8 100644 --- a/include/BSMPT/models/IncludeAllModels.h +++ b/include/BSMPT/models/IncludeAllModels.h @@ -103,6 +103,12 @@ ModelIDs getModel(const std::string &s); */ void ShowInputError(); +/** + * @brief operator << overload for the model parameter + */ +std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model); +std::string ModelIDToString(const ModelID::ModelIDs &Model); + } // namespace BSMPT // #endif /* INCLUDEALLMODELS_H_ */ diff --git a/include/BSMPT/utility/utility.h b/include/BSMPT/utility/utility.h index 8d06ce5b..d3f8c453 100644 --- a/include/BSMPT/utility/utility.h +++ b/include/BSMPT/utility/utility.h @@ -284,15 +284,7 @@ double Li2(const double &x); */ double EllipIntSecond(const double &x); -/** - * @brief operator << overload for the model parameter - */ -namespace ModelID -{ -enum class ModelIDs; -} -std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model); -std::string ModelIDToString(const ModelID::ModelIDs &Model); + #ifdef Boost_FOUND #if BOOST_VERSION >= 107200 diff --git a/src/models/IncludeAllModels.cpp b/src/models/IncludeAllModels.cpp index 0fd8dcb1..9cfc6d98 100644 --- a/src/models/IncludeAllModels.cpp +++ b/src/models/IncludeAllModels.cpp @@ -108,4 +108,20 @@ void ShowInputError() Logger::Write(LoggingLevel::Default, ss.str()); } + +std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model) +{ + static auto IMN = BSMPT::ModelID::InvertModelNames(); + os << IMN.at(Model); + return os; +} + + +std::string ModelIDToString(const ModelID::ModelIDs &Model) +{ + std::stringstream ss; + ss << Model; + return ss.str(); +} + } // namespace BSMPT diff --git a/src/utility/utility.cpp b/src/utility/utility.cpp index 300066a8..3b57192b 100644 --- a/src/utility/utility.cpp +++ b/src/utility/utility.cpp @@ -16,12 +16,6 @@ namespace BSMPT { -std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model) -{ - static auto IMN = BSMPT::ModelID::InvertModelNames(); - os << IMN.at(Model); - return os; -} std::vector split(const std::string &str, char delimiter) { @@ -36,12 +30,6 @@ std::vector split(const std::string &str, char delimiter) return res; } -std::string ModelIDToString(const ModelID::ModelIDs &Model) -{ - std::stringstream ss; - ss << Model; - return ss.str(); -} bool StringStartsWith(const std::string &str, const std::string &prefix) { diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 3e5af26a..65a59bcd 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries(example bsmpt::Utility) \ No newline at end of file +target_link_libraries(example bsmpt::Utility bsmpt::BounceSolution bsmpt::Models) \ No newline at end of file diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index b9e5c4b3..db3dd525 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -1,6 +1,6 @@ -//#include -//#include -//#include +#include +#include +#include #include /*#include #include @@ -10,4 +10,5 @@ #include */ int main() { + BSMPT::Logger::Disable(); } diff --git a/tools/cmake/CompilerOptions.cmake b/tools/cmake/CompilerOptions.cmake index dd6822ce..d48da3d9 100644 --- a/tools/cmake/CompilerOptions.cmake +++ b/tools/cmake/CompilerOptions.cmake @@ -3,6 +3,10 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +add_compile_definitions( + $<$,$,$>:_GLIBCXX_USE_CXX11_ABI=1> + ) + add_compile_options( $<$:-DCOMPILEDEBUG=true> $<$,$,$>:-pedantic> From 6d9add05ecc7ad0dacf5edaca10f3d5681b0a8a8 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 22:41:20 +0200 Subject: [PATCH 15/69] move modelid to utility --- include/BSMPT/models/ClassPotentialOrigin.h | 6 +- include/BSMPT/models/IncludeAllModels.h | 51 +--------------- include/BSMPT/utility/ModelIDs.h | 64 +++++++++++++++++++++ include/BSMPT/utility/settings.h | 9 +++ src/models/IncludeAllModels.cpp | 47 --------------- src/utility/CMakeLists.txt | 6 +- src/utility/ModelIDs.cpp | 60 +++++++++++++++++++ src/utility/parser.cpp | 1 + test_package/CMakeLists.txt | 2 +- 9 files changed, 142 insertions(+), 104 deletions(-) create mode 100644 include/BSMPT/utility/ModelIDs.h create mode 100644 include/BSMPT/utility/settings.h create mode 100644 src/utility/ModelIDs.cpp diff --git a/include/BSMPT/models/ClassPotentialOrigin.h b/include/BSMPT/models/ClassPotentialOrigin.h index 4c791f3f..72f120e7 100644 --- a/include/BSMPT/models/ClassPotentialOrigin.h +++ b/include/BSMPT/models/ClassPotentialOrigin.h @@ -15,16 +15,14 @@ #include #include #include +#include #include #include namespace BSMPT { -/** - * @brief C_UseParwani Use the Parwani Method instead of Arnold-Espinosa - */ -const bool C_UseParwani = false; + /** * @brief C_PT Lower threshold to stop the EWPT calculation diff --git a/include/BSMPT/models/IncludeAllModels.h b/include/BSMPT/models/IncludeAllModels.h index c889bfc8..65613611 100644 --- a/include/BSMPT/models/IncludeAllModels.h +++ b/include/BSMPT/models/IncludeAllModels.h @@ -14,6 +14,7 @@ #include // for string #include #include +#include /** * @file @@ -25,45 +26,6 @@ class Class_Potential_Origin; namespace ModelID { -/** - * @brief The ModelIDs enum containing all IDs for identifying the Models - */ -enum class ModelIDs -{ - NotSet, - C2HDM, - R2HDM, - N2HDM, - CXSM, - CPINTHEDARK, - SM, - - // Here you start adding your models - TEMPLATE, - - // DO NOT EDIT the part below - stop -}; - -/** - * @brief Mapping between the model name which is given as the first argument to - * the binary and the ModelIDs element - */ -const std::unordered_map ModelNames{ - {"c2hdm", ModelIDs::C2HDM}, - {"r2hdm", ModelIDs::R2HDM}, - {"n2hdm", ModelIDs::N2HDM}, - {"cxsm", ModelIDs::CXSM}, - {"sm", ModelIDs::SM}, - {"cpinthedark", ModelIDs::CPINTHEDARK}, - {"template", ModelIDs::TEMPLATE}, -}; - -/** - * @brief InvertModelNames - * @return The switched map to ModelNames - */ -std::unordered_map InvertModelNames(); /** * @param choice ModelIDs for the Model under investigation @@ -98,17 +60,6 @@ FChoose(ModelIDs choice, const ISMConstants &smConstants); ModelIDs getModel(const std::string &s); } // namespace ModelID -/** - * @brief ShowInputError shows all the available models in the terminal - */ -void ShowInputError(); - -/** - * @brief operator << overload for the model parameter - */ -std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model); -std::string ModelIDToString(const ModelID::ModelIDs &Model); - } // namespace BSMPT // #endif /* INCLUDEALLMODELS_H_ */ diff --git a/include/BSMPT/utility/ModelIDs.h b/include/BSMPT/utility/ModelIDs.h new file mode 100644 index 00000000..b4c7a7ae --- /dev/null +++ b/include/BSMPT/utility/ModelIDs.h @@ -0,0 +1,64 @@ +#pragma once + +#include +#include + +namespace BSMPT +{ + namespace ModelID +{ + +/** + * @brief The ModelIDs enum containing all IDs for identifying the Models + */ +enum class ModelIDs +{ + NotSet, + C2HDM, + R2HDM, + N2HDM, + CXSM, + CPINTHEDARK, + SM, + + // Here you start adding your models + TEMPLATE, + + // DO NOT EDIT the part below + stop +}; + +/** + * @brief Mapping between the model name which is given as the first argument to + * the binary and the ModelIDs element + */ +const std::unordered_map ModelNames{ + {"c2hdm", ModelIDs::C2HDM}, + {"r2hdm", ModelIDs::R2HDM}, + {"n2hdm", ModelIDs::N2HDM}, + {"cxsm", ModelIDs::CXSM}, + {"sm", ModelIDs::SM}, + {"cpinthedark", ModelIDs::CPINTHEDARK}, + {"template", ModelIDs::TEMPLATE}, +}; + +/** + * @brief InvertModelNames + * @return The switched map to ModelNames + */ +std::unordered_map InvertModelNames(); +} + + +/** + * @brief ShowInputError shows all the available models in the terminal + */ +void ShowInputError(); + +/** + * @brief operator << overload for the model parameter + */ +std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model); +std::string ModelIDToString(const ModelID::ModelIDs &Model); + +} \ No newline at end of file diff --git a/include/BSMPT/utility/settings.h b/include/BSMPT/utility/settings.h new file mode 100644 index 00000000..42c515a0 --- /dev/null +++ b/include/BSMPT/utility/settings.h @@ -0,0 +1,9 @@ +#pragma once + +namespace BSMPT +{ + /** + * @brief C_UseParwani Use the Parwani Method instead of Arnold-Espinosa + */ +const bool C_UseParwani = false; +} // namespace BSMPT diff --git a/src/models/IncludeAllModels.cpp b/src/models/IncludeAllModels.cpp index 9cfc6d98..7ea1dcb6 100644 --- a/src/models/IncludeAllModels.cpp +++ b/src/models/IncludeAllModels.cpp @@ -75,53 +75,6 @@ ModelIDs getModel(const std::string &s) return ModelIDs::NotSet; } -std::unordered_map InvertModelNames() -{ - std::unordered_map IMN; - for (const auto &el : ModelNames) - { - auto success = IMN.emplace(el.second, el.first); - if (not success.second) - { - throw std::runtime_error( - "\nERROR: The same ModelID is assigned for two different models.\n"); - } - } - return IMN; -} - } // namespace ModelID -void ShowInputError() -{ - std::stringstream ss; - ss << "The chosen Method for the thermal mass corrections is "; - if (C_UseParwani) - ss << "Parwani "; - else - ss << "Arnold Espinosa\n"; - ss << "The implemented models are " << std::endl; - for (auto entry : ModelID::ModelNames) - { - ss << entry.first << std::endl; - } - Logger::Write(LoggingLevel::Default, ss.str()); -} - - -std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model) -{ - static auto IMN = BSMPT::ModelID::InvertModelNames(); - os << IMN.at(Model); - return os; -} - - -std::string ModelIDToString(const ModelID::ModelIDs &Model) -{ - std::stringstream ss; - ss << Model; - return ss.str(); -} - } // namespace BSMPT diff --git a/src/utility/CMakeLists.txt b/src/utility/CMakeLists.txt index a2ae3677..5a27de00 100644 --- a/src/utility/CMakeLists.txt +++ b/src/utility/CMakeLists.txt @@ -8,9 +8,11 @@ set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/utility.h ${header_path}/Logger.h ${header_path}/parser.h ${header_path}/const_velocity_spline.h - ${header_path}/NumericalDerivatives.h) + ${header_path}/NumericalDerivatives.h + ${header_path}/ModelIDs.h + ${header_path}/settings.h) set(src utility.cpp Logger.cpp parser.cpp const_velocity_spline.cpp - NumericalDerivatives.cpp) + NumericalDerivatives.cpp ModelIDs.cpp) add_library(Utility ${header} ${src}) target_include_directories(Utility PUBLIC ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) diff --git a/src/utility/ModelIDs.cpp b/src/utility/ModelIDs.cpp new file mode 100644 index 00000000..770d1711 --- /dev/null +++ b/src/utility/ModelIDs.cpp @@ -0,0 +1,60 @@ +#include +#include // for runtime_error +#include +#include +#include +#include + +namespace BSMPT +{ +namespace ModelID +{ + +std::unordered_map InvertModelNames() +{ + std::unordered_map IMN; + for (const auto &el : ModelNames) + { + auto success = IMN.emplace(el.second, el.first); + if (not success.second) + { + throw std::runtime_error( + "\nERROR: The same ModelID is assigned for two different models.\n"); + } + } + return IMN; +} + +} // namespace ModelID + +void ShowInputError() +{ + std::stringstream ss; + ss << "The chosen Method for the thermal mass corrections is "; + if (C_UseParwani) + ss << "Parwani "; + else + ss << "Arnold Espinosa\n"; + ss << "The implemented models are " << std::endl; + for (auto entry : ModelID::ModelNames) + { + ss << entry.first << std::endl; + } + Logger::Write(LoggingLevel::Default, ss.str()); +} + +std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model) +{ + static auto IMN = BSMPT::ModelID::InvertModelNames(); + os << IMN.at(Model); + return os; +} + +std::string ModelIDToString(const ModelID::ModelIDs &Model) +{ + std::stringstream ss; + ss << Model; + return ss.str(); +} + +} // namespace BSMPT \ No newline at end of file diff --git a/src/utility/parser.cpp b/src/utility/parser.cpp index 2f838bb4..48361590 100644 --- a/src/utility/parser.cpp +++ b/src/utility/parser.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 65a59bcd..6ce9f9bd 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries(example bsmpt::Utility bsmpt::BounceSolution bsmpt::Models) \ No newline at end of file +target_link_libraries(example bsmpt::Utility bsmpt::BounceSolution) \ No newline at end of file From e52b60994919259eacd9faec595f04b74f147357 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 22:55:50 +0200 Subject: [PATCH 16/69] Call model --- test_package/src/example.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index db3dd525..221a5ae3 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -2,13 +2,16 @@ #include #include #include -/*#include +#include #include #include #include #include -#include */ +#include int main() { - BSMPT::Logger::Disable(); + using namespace BSMPT; + Logger::Disable(); + ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); + } From a12228246c074ef59e46ded5ebc0113ac5580743 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 23:47:46 +0200 Subject: [PATCH 17/69] build all --- .github/workflows/conan.yml | 2 +- conanfile.py | 14 ++++++++++++-- test_package/CMakeLists.txt | 2 +- test_package/src/example.cpp | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index d3adee00..5196c9e3 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -21,7 +21,7 @@ jobs: conan: strategy: matrix: - os: [ ubuntu-latest] + os: [ ubuntu-latest, windows-latest, macos-latest] runs-on: ${{matrix.os}} if: "!contains(github.event.head_commit.message, 'skip-ci')" diff --git a/conanfile.py b/conanfile.py index 5668d0c7..1e7aeb05 100644 --- a/conanfile.py +++ b/conanfile.py @@ -42,8 +42,8 @@ class BSMPT(ConanFile): "BuildExecutables": [True,False] } default_options = { - "EnableTests": False, - "UseLibCMAES": False, + "EnableTests": True, + "UseLibCMAES": True, "UseNLopt": True, "MakeAdditionalTesting": False, "CompileBaryo": False, @@ -143,6 +143,7 @@ def package_info(self): self.cpp_info.components["ASCIIPlotter"].requires = [ "nlohmann_json::nlohmann_json", ] + self.cpp_info.components["ASCIIPlotter"].set_property("cmake_target_name", "BSMPT::ASCIIPlotter") if self.options.CompileBaryo: self.cpp_info.components["ASCIIPlotter"].requires.append( @@ -153,6 +154,7 @@ def package_info(self): self.cpp_info.components["Spline"].requires = [ "nlohmann_json::nlohmann_json", ] + self.cpp_info.components["Spline"].set_property("cmake_target_name", "BSMPT::Spline") if self.options.CompileBaryo: self.cpp_info.components["Spline"].requires.append( @@ -166,6 +168,7 @@ def package_info(self): "ASCIIPlotter", "Spline", ] + self.cpp_info.components["Utility"].set_property("cmake_target_name", "BSMPT::Utility") if self.options.CompileBaryo: self.cpp_info.components["Utility"].requires.append( @@ -180,6 +183,7 @@ def package_info(self): "Utility", "MinimumTracer", ] + self.cpp_info.components["BounceSolution"].set_property("cmake_target_name", "BSMPT::BounceSolution") self.cpp_info.components["GW"].libs = ["GW"] self.cpp_info.components["GW"].requires = [ @@ -189,6 +193,7 @@ def package_info(self): "Utility", "BounceSolution", ] + self.cpp_info.components["GW"].set_property("cmake_target_name", "BSMPT::GW") self.cpp_info.components["Minimizer"].libs = ["Minimizer"] self.cpp_info.components["Minimizer"].requires = [ @@ -199,6 +204,7 @@ def package_info(self): "Models", # "Minimizer_CMAES" ] + self.cpp_info.components["Minimizer"].set_property("cmake_target_name", "BSMPT::Minimizer") if self.options.UseNLopt: @@ -213,6 +219,7 @@ def package_info(self): "Minimizer", "Utility", ] + self.cpp_info.components["MinimumTracer"].set_property("cmake_target_name", "BSMPT::MinimumTracer") self.cpp_info.components["Models"].libs = ["Models"] self.cpp_info.components["Models"].requires = [ @@ -222,9 +229,11 @@ def package_info(self): "ThermalFunctions", "Utility", ] + self.cpp_info.components["Models"].set_property("cmake_target_name", "BSMPT::Models") self.cpp_info.components["ThermalFunctions"].libs = ["ThermalFunctions"] self.cpp_info.components["ThermalFunctions"].requires = ["gsl::gsl", "Utility"] + self.cpp_info.components["ThermalFunctions"].set_property("cmake_target_name", "BSMPT::ThermalFunctions") self.cpp_info.components["TransitionTracer"].libs = ["TransitionTracer"] self.cpp_info.components["TransitionTracer"].requires = [ @@ -232,3 +241,4 @@ def package_info(self): "MinimumTracer", "GW", ] + self.cpp_info.components["TransitionTracer"].set_property("cmake_target_name", "BSMPT::TransitionTracer") diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 6ce9f9bd..28acd377 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries(example bsmpt::Utility bsmpt::BounceSolution) \ No newline at end of file +target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::Models BSMPT::Minimzer ) \ No newline at end of file diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index 221a5ae3..97e6f84f 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -13,5 +13,6 @@ int main() { using namespace BSMPT; Logger::Disable(); ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); + Minimizer::CalcWhichMinimizer(); } From d08d39d5d2101455873d2aae14c1b7ce130fffeb Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 23:52:19 +0200 Subject: [PATCH 18/69] dont build unit tests for package creation --- Setup.py | 2 ++ conanfile.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Setup.py b/Setup.py index 433e9e69..b2d20927 100644 --- a/Setup.py +++ b/Setup.py @@ -203,6 +203,8 @@ def create(build_missing=False): if build_missing: cmd += ["--build=missing"] + cmd += ["--options", "EnableTests=False"] + subprocess.check_call(cmd) diff --git a/conanfile.py b/conanfile.py index 1e7aeb05..133f5619 100644 --- a/conanfile.py +++ b/conanfile.py @@ -137,6 +137,9 @@ def package(self): cmake = CMake(self) cmake.install() + def package_id(self): + del self.info.options.EnableTests + def package_info(self): self.cpp_info.components["ASCIIPlotter"].libs = ["ASCIIPlotter"] From b3325e53e1fa56f8748266f4b2e33f5c3c02b158 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 23:56:03 +0200 Subject: [PATCH 19/69] BuildExecutables True per default and false in create script --- Setup.py | 2 +- conanfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Setup.py b/Setup.py index b2d20927..841f8732 100644 --- a/Setup.py +++ b/Setup.py @@ -203,7 +203,7 @@ def create(build_missing=False): if build_missing: cmd += ["--build=missing"] - cmd += ["--options", "EnableTests=False"] + cmd += ["--options", "EnableTests=False", "BuildExecutables=False"] subprocess.check_call(cmd) diff --git a/conanfile.py b/conanfile.py index 133f5619..27eab0ba 100644 --- a/conanfile.py +++ b/conanfile.py @@ -49,7 +49,7 @@ class BSMPT(ConanFile): "CompileBaryo": False, "EnableCoverage": False, "UseVectorization": True, - "BuildExecutables": False + "BuildExecutables": True } def requirements(self): From 223e25bc5816ba62b1e5fa1b6191e9809e63a209 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Sun, 2 Jun 2024 23:57:40 +0200 Subject: [PATCH 20/69] fix typo --- test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 28acd377..bbad4815 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::Models BSMPT::Minimzer ) \ No newline at end of file +target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::Models BSMPT::Minimizer ) \ No newline at end of file From df4c65f5bb73b99ad3f4e03306a83e2dca6d4dbf Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:09:11 +0200 Subject: [PATCH 21/69] Update Setup.py --- Setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Setup.py b/Setup.py index 841f8732..d3953d2a 100644 --- a/Setup.py +++ b/Setup.py @@ -203,7 +203,8 @@ def create(build_missing=False): if build_missing: cmd += ["--build=missing"] - cmd += ["--options", "EnableTests=False", "BuildExecutables=False"] + cmd += ["--options", "EnableTests=False"] + cmd += ["--options", "BuildExecutables=False"] subprocess.check_call(cmd) From b61b06158f40f033589226ef9b2a7f49e17a3706 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:20:33 +0200 Subject: [PATCH 22/69] disable cmaes --- Setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Setup.py b/Setup.py index d3953d2a..369559bb 100644 --- a/Setup.py +++ b/Setup.py @@ -205,6 +205,7 @@ def create(build_missing=False): cmd += ["--options", "EnableTests=False"] cmd += ["--options", "BuildExecutables=False"] + cmd += ["--options", "UseLibCMAES=False"] subprocess.check_call(cmd) From 059d6f342cf2bf4001f06da854b1b73a952a83a1 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Mon, 3 Jun 2024 06:32:02 +0200 Subject: [PATCH 23/69] enable cmaes and minimize in test_package --- Setup.py | 1 - conanfile.py | 5 +++++ test_package/src/example.cpp | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Setup.py b/Setup.py index 369559bb..d3953d2a 100644 --- a/Setup.py +++ b/Setup.py @@ -205,7 +205,6 @@ def create(build_missing=False): cmd += ["--options", "EnableTests=False"] cmd += ["--options", "BuildExecutables=False"] - cmd += ["--options", "UseLibCMAES=False"] subprocess.check_call(cmd) diff --git a/conanfile.py b/conanfile.py index 27eab0ba..22442c0f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -178,6 +178,7 @@ def package_info(self): "boost::boost", ) + self.cpp_info.components["BounceSolution"].libs = ["BounceSolution"] self.cpp_info.components["BounceSolution"].requires = [ "eigen::eigen", @@ -209,6 +210,10 @@ def package_info(self): ] self.cpp_info.components["Minimizer"].set_property("cmake_target_name", "BSMPT::Minimizer") + if self.options.UseLibCMAES: + self.cpp_info.components["libcmaes"].libs= ["libcmaes"] + self.cpp_info.components["Minimizer"].requires.append("libcmaes") + if self.options.UseNLopt: self.cpp_info.components["Minimizer"].requires = [ diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index 97e6f84f..623e6c57 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -12,7 +12,11 @@ int main() { using namespace BSMPT; Logger::Disable(); - ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); + auto testModel = ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); Minimizer::CalcWhichMinimizer(); + std::vector check; + std::vector start(0,8); + Minimize_gen_all(testModel,0,check,start); + } From 35f4f0bb4df87de9026ce9a25cd6b8f867eada49 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Mon, 3 Jun 2024 06:45:57 +0200 Subject: [PATCH 24/69] build cmaes static and set component name --- conanfile.py | 2 ++ tools/cmake/CMAES.cmake | 1 + 2 files changed, 3 insertions(+) diff --git a/conanfile.py b/conanfile.py index 22442c0f..ace328b0 100644 --- a/conanfile.py +++ b/conanfile.py @@ -212,6 +212,8 @@ def package_info(self): if self.options.UseLibCMAES: self.cpp_info.components["libcmaes"].libs= ["libcmaes"] + self.cpp_info.components["libcmaes"].set_property("cmake_target_name", "BSMPT::libcmaes") + self.cpp_info.components["Minimizer"].requires.append("libcmaes") if self.options.UseNLopt: diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 99b34f8c..25fb7948 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -15,6 +15,7 @@ if(NOT libcmaes_FOUND) option(LIBCMAES_BUILD_PYTHON OFF) option(LIBCMAES_BUILD_EXAMPLES OFF) option(LIBCMAES_USE_OPENMP OpenMP_FOUND) + option(LIBCMAES_BUILD_SHARED_LIBS OFF) FetchContent_Populate(libcmaes) add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) include(GenerateExportHeader) From 7611b308664cc98da8155574c82980674bcea1cf Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Mon, 3 Jun 2024 07:01:45 +0200 Subject: [PATCH 25/69] Fix wrong lib name --- conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index ace328b0..1a39eca2 100644 --- a/conanfile.py +++ b/conanfile.py @@ -211,9 +211,9 @@ def package_info(self): self.cpp_info.components["Minimizer"].set_property("cmake_target_name", "BSMPT::Minimizer") if self.options.UseLibCMAES: - self.cpp_info.components["libcmaes"].libs= ["libcmaes"] - self.cpp_info.components["libcmaes"].set_property("cmake_target_name", "BSMPT::libcmaes") - + self.cpp_info.components["libcmaes"].libs= ["cmaes"] + self.cpp_info.components["libcmaes"].set_property("cmake_target_name", "BSMPT::cmaes") + self.cpp_info.components["Minimizer"].requires.append("libcmaes") if self.options.UseNLopt: From e06d96dc0332f003d9cc9cf29625e6a05265a98f Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Mon, 3 Jun 2024 07:12:13 +0200 Subject: [PATCH 26/69] add fpic and reset cmaes to shared --- conanfile.py | 7 ++++--- test_package/src/example.cpp | 19 +++++++++++++++++-- tools/cmake/CMAES.cmake | 1 - 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1a39eca2..954b1293 100644 --- a/conanfile.py +++ b/conanfile.py @@ -26,6 +26,7 @@ class BSMPT(ConanFile): ) options = { + "fPIC": [True, False], "EnableTests": [True, False], # enables the unit tests "UseLibCMAES": [ True, @@ -42,6 +43,7 @@ class BSMPT(ConanFile): "BuildExecutables": [True,False] } default_options = { + "fPIC": True, "EnableTests": True, "UseLibCMAES": True, "UseNLopt": True, @@ -124,9 +126,8 @@ def validate(self): tools.build.check_min_cppstd(self, "17") def config_options(self): - pass - # if self.settings.os == "Windows": - # del self.options.fPIC + if self.settings.os == "Windows": + del self.options.fPIC def build(self): cmake = CMake(self) diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index 623e6c57..8e6a7f68 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -12,11 +12,26 @@ int main() { using namespace BSMPT; Logger::Disable(); - auto testModel = ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); + std::shared_ptr testModel = ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); Minimizer::CalcWhichMinimizer(); + const std::vector example_point_C2HDM{/* lambda_1 = */ 3.29771, + /* lambda_2 = */ 0.274365, + /* lambda_3 = */ 4.71019, + /* lambda_4 = */ -2.23056, + /* Re(lambda_5) = */ -2.43487, + /* Im(lambda_5) = */ 0.124948, + /* Re(m_{12}^2) = */ 2706.86, + /* tan(beta) = */ 4.64487, + /* Yukawa Type = */ 1}; + + testModel->initModel(example_point_C2HDM); + std::vector check; std::vector start(0,8); - Minimize_gen_all(testModel,0,check,start); + auto result = Minimizer::Minimize_gen_all(testModel,0,check,start); + std::cout << "result = " << result << std::endl; + + } diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 25fb7948..99b34f8c 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -15,7 +15,6 @@ if(NOT libcmaes_FOUND) option(LIBCMAES_BUILD_PYTHON OFF) option(LIBCMAES_BUILD_EXAMPLES OFF) option(LIBCMAES_USE_OPENMP OpenMP_FOUND) - option(LIBCMAES_BUILD_SHARED_LIBS OFF) FetchContent_Populate(libcmaes) add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) include(GenerateExportHeader) From 37430b764e87ccd89bbcd117bf83d47d67c17dc1 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Mon, 3 Jun 2024 07:17:21 +0200 Subject: [PATCH 27/69] set cmaes to static library --- tools/cmake/CMAES.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 99b34f8c..25fb7948 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -15,6 +15,7 @@ if(NOT libcmaes_FOUND) option(LIBCMAES_BUILD_PYTHON OFF) option(LIBCMAES_BUILD_EXAMPLES OFF) option(LIBCMAES_USE_OPENMP OpenMP_FOUND) + option(LIBCMAES_BUILD_SHARED_LIBS OFF) FetchContent_Populate(libcmaes) add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) include(GenerateExportHeader) From fa96851877a5005187226536f726b0fbf9e26ab6 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 19:27:47 +0200 Subject: [PATCH 28/69] add cmaes dependencies for static library --- conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conanfile.py b/conanfile.py index 954b1293..4e323470 100644 --- a/conanfile.py +++ b/conanfile.py @@ -65,6 +65,9 @@ def requirements(self): if self.options.UseNLopt: self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) + if self.options.UseLibCMAES: + self.requires("llvm-openmp/17.0.6", transitive_headers=True) + def build_requirements(self): self.tool_requires("cmake/3.29.0") From c60db12d22cd4882c61dc6e63fe220b8383bf52e Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 19:35:26 +0200 Subject: [PATCH 29/69] dont use openmp on windows --- conanfile.py | 2 +- tools/cmake/CMAES.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index 4e323470..a83892a4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -65,7 +65,7 @@ def requirements(self): if self.options.UseNLopt: self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) - if self.options.UseLibCMAES: + if self.options.UseLibCMAES and self.settings.os != "Windows": self.requires("llvm-openmp/17.0.6", transitive_headers=True) def build_requirements(self): diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 25fb7948..e8f5b703 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -1,4 +1,4 @@ -find_package(OpenMP QUIET) +find_package(OpenMP::OpenMP QUIET) find_package(libcmaes 0.10 QUIET) if(NOT libcmaes_FOUND) set(BSMPT_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") From 5819b20abe5c900255f7be480e2e18d23f2fef86 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 19:40:30 +0200 Subject: [PATCH 30/69] add misisng require component --- conanfile.py | 3 +++ tools/cmake/CMAES.cmake | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index a83892a4..50b9eeaf 100644 --- a/conanfile.py +++ b/conanfile.py @@ -217,6 +217,9 @@ def package_info(self): if self.options.UseLibCMAES: self.cpp_info.components["libcmaes"].libs= ["cmaes"] self.cpp_info.components["libcmaes"].set_property("cmake_target_name", "BSMPT::cmaes") + self.cpp_info.components["libcmaes"].requires = ["eigen::eigen"] + if self.settings.os != "Windows": + self.cpp_info.components["libcmaes"].requires = ["openmp::openmp"] self.cpp_info.components["Minimizer"].requires.append("libcmaes") diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index e8f5b703..b7914599 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -1,4 +1,4 @@ -find_package(OpenMP::OpenMP QUIET) +find_package(OpenMP CONFIG QUIET) find_package(libcmaes 0.10 QUIET) if(NOT libcmaes_FOUND) set(BSMPT_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") From 2e4e0b25093206383f614176af7481800eee8b80 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 19:48:23 +0200 Subject: [PATCH 31/69] fix name in requirement --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 50b9eeaf..35b06426 100644 --- a/conanfile.py +++ b/conanfile.py @@ -219,7 +219,7 @@ def package_info(self): self.cpp_info.components["libcmaes"].set_property("cmake_target_name", "BSMPT::cmaes") self.cpp_info.components["libcmaes"].requires = ["eigen::eigen"] if self.settings.os != "Windows": - self.cpp_info.components["libcmaes"].requires = ["openmp::openmp"] + self.cpp_info.components["libcmaes"].requires = ["llvm-openmp::llvm-openmp"] self.cpp_info.components["Minimizer"].requires.append("libcmaes") From d5ca190f8d9ab6d33b1959be31fa01be38c83c3c Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:06:03 +0200 Subject: [PATCH 32/69] link whole archiv --- src/minimizer/LibCMAES/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt index 06335ef3..56bff7c5 100644 --- a/src/minimizer/LibCMAES/CMakeLists.txt +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -12,6 +12,7 @@ target_sources(Minimizer_CMAES INTERFACE MinimizeLibCMAES.cpp ${header}) target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) +target_link_libraries(Minimizer_CMAES INTERFACE "$") if(OpenMP_FOUND) target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) endif() @@ -26,4 +27,4 @@ set_property(TARGET Minimizer_CMAES PROPERTY PUBLIC_HEADER ${header}) install( TARGETS Minimizer_CMAES PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +) From a9b130678b285418c32294fb35ae613c51fc6d5c Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:07:51 +0200 Subject: [PATCH 33/69] Comment default options --- src/minimizer/LibCMAES/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt index 56bff7c5..ed1ddcd3 100644 --- a/src/minimizer/LibCMAES/CMakeLists.txt +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(Minimizer_CMAES INTERFACE) target_sources(Minimizer_CMAES INTERFACE MinimizeLibCMAES.cpp ${header}) target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) -target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) +# target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) target_link_libraries(Minimizer_CMAES INTERFACE "$") if(OpenMP_FOUND) target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) From cc47dbeaf67c93878f1b5f6a6734dd819553c16d Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Sun, 14 Jul 2024 18:23:40 +0000 Subject: [PATCH 34/69] Automatically applied linter --- include/BSMPT/models/ClassPotentialOrigin.h | 2 - include/BSMPT/models/IncludeAllModels.h | 3 +- include/BSMPT/utility/ModelIDs.h | 9 ++-- include/BSMPT/utility/settings.h | 2 +- include/BSMPT/utility/utility.h | 2 - src/utility/ModelIDs.cpp | 6 +-- src/utility/parser.cpp | 2 +- src/utility/utility.cpp | 2 - test_package/src/example.cpp | 51 ++++++++++----------- 9 files changed, 35 insertions(+), 44 deletions(-) diff --git a/include/BSMPT/models/ClassPotentialOrigin.h b/include/BSMPT/models/ClassPotentialOrigin.h index 72f120e7..9d0bcba0 100644 --- a/include/BSMPT/models/ClassPotentialOrigin.h +++ b/include/BSMPT/models/ClassPotentialOrigin.h @@ -22,8 +22,6 @@ namespace BSMPT { - - /** * @brief C_PT Lower threshold to stop the EWPT calculation */ diff --git a/include/BSMPT/models/IncludeAllModels.h b/include/BSMPT/models/IncludeAllModels.h index 65613611..0ce09a3c 100644 --- a/include/BSMPT/models/IncludeAllModels.h +++ b/include/BSMPT/models/IncludeAllModels.h @@ -9,12 +9,12 @@ #pragma once +#include #include // for max #include #include // for string #include #include -#include /** * @file @@ -26,7 +26,6 @@ class Class_Potential_Origin; namespace ModelID { - /** * @param choice ModelIDs for the Model under investigation * @return smart pointer to the instance of the class matching the ModelIDs diff --git a/include/BSMPT/utility/ModelIDs.h b/include/BSMPT/utility/ModelIDs.h index b4c7a7ae..5e6ab228 100644 --- a/include/BSMPT/utility/ModelIDs.h +++ b/include/BSMPT/utility/ModelIDs.h @@ -1,11 +1,11 @@ #pragma once -#include #include +#include namespace BSMPT { - namespace ModelID +namespace ModelID { /** @@ -47,8 +47,7 @@ const std::unordered_map ModelNames{ * @return The switched map to ModelNames */ std::unordered_map InvertModelNames(); -} - +} // namespace ModelID /** * @brief ShowInputError shows all the available models in the terminal @@ -61,4 +60,4 @@ void ShowInputError(); std::ostream &operator<<(std::ostream &os, const ModelID::ModelIDs &Model); std::string ModelIDToString(const ModelID::ModelIDs &Model); -} \ No newline at end of file +} // namespace BSMPT \ No newline at end of file diff --git a/include/BSMPT/utility/settings.h b/include/BSMPT/utility/settings.h index 42c515a0..c6113f38 100644 --- a/include/BSMPT/utility/settings.h +++ b/include/BSMPT/utility/settings.h @@ -2,7 +2,7 @@ namespace BSMPT { - /** +/** * @brief C_UseParwani Use the Parwani Method instead of Arnold-Espinosa */ const bool C_UseParwani = false; diff --git a/include/BSMPT/utility/utility.h b/include/BSMPT/utility/utility.h index d3f8c453..75a25be2 100644 --- a/include/BSMPT/utility/utility.h +++ b/include/BSMPT/utility/utility.h @@ -284,8 +284,6 @@ double Li2(const double &x); */ double EllipIntSecond(const double &x); - - #ifdef Boost_FOUND #if BOOST_VERSION >= 107200 template diff --git a/src/utility/ModelIDs.cpp b/src/utility/ModelIDs.cpp index 770d1711..3b1c925f 100644 --- a/src/utility/ModelIDs.cpp +++ b/src/utility/ModelIDs.cpp @@ -1,9 +1,9 @@ -#include -#include // for runtime_error -#include #include +#include #include #include +#include +#include // for runtime_error namespace BSMPT { diff --git a/src/utility/parser.cpp b/src/utility/parser.cpp index 48361590..3ec6f5f1 100644 --- a/src/utility/parser.cpp +++ b/src/utility/parser.cpp @@ -5,9 +5,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/src/utility/utility.cpp b/src/utility/utility.cpp index 3b57192b..402c09ba 100644 --- a/src/utility/utility.cpp +++ b/src/utility/utility.cpp @@ -16,7 +16,6 @@ namespace BSMPT { - std::vector split(const std::string &str, char delimiter) { // Using str in a string stream @@ -30,7 +29,6 @@ std::vector split(const std::string &str, char delimiter) return res; } - bool StringStartsWith(const std::string &str, const std::string &prefix) { return str.size() >= prefix.size() and str.find(prefix) == 0; diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index 8e6a7f68..fd4d656b 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -1,37 +1,36 @@ -#include -#include -#include +#include #include #include #include #include #include -#include #include +#include +#include +#include -int main() { - using namespace BSMPT; - Logger::Disable(); - std::shared_ptr testModel = ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); - Minimizer::CalcWhichMinimizer(); - - const std::vector example_point_C2HDM{/* lambda_1 = */ 3.29771, - /* lambda_2 = */ 0.274365, - /* lambda_3 = */ 4.71019, - /* lambda_4 = */ -2.23056, - /* Re(lambda_5) = */ -2.43487, - /* Im(lambda_5) = */ 0.124948, - /* Re(m_{12}^2) = */ 2706.86, - /* tan(beta) = */ 4.64487, - /* Yukawa Type = */ 1}; - - testModel->initModel(example_point_C2HDM); - - std::vector check; - std::vector start(0,8); - auto result = Minimizer::Minimize_gen_all(testModel,0,check,start); - std::cout << "result = " << result << std::endl; +int main() +{ + using namespace BSMPT; + Logger::Disable(); + std::shared_ptr testModel = + ModelID::FChoose(ModelID::ModelIDs::C2HDM, GetSMConstants()); + Minimizer::CalcWhichMinimizer(); + const std::vector example_point_C2HDM{/* lambda_1 = */ 3.29771, + /* lambda_2 = */ 0.274365, + /* lambda_3 = */ 4.71019, + /* lambda_4 = */ -2.23056, + /* Re(lambda_5) = */ -2.43487, + /* Im(lambda_5) = */ 0.124948, + /* Re(m_{12}^2) = */ 2706.86, + /* tan(beta) = */ 4.64487, + /* Yukawa Type = */ 1}; + testModel->initModel(example_point_C2HDM); + std::vector check; + std::vector start(0, 8); + auto result = Minimizer::Minimize_gen_all(testModel, 0, check, start); + std::cout << "result = " << result << std::endl; } From 349ee38bf628de00b46afbc4fc64ffff95bf86d1 Mon Sep 17 00:00:00 2001 From: phbasler Date: Sun, 14 Jul 2024 18:23:48 +0000 Subject: [PATCH 35/69] Automated commit of cmake-format changes. --- CMakeLists.txt | 15 ++- src/CMakeLists.txt | 159 ++++++++++++------------ src/ThermalFunctions/CMakeLists.txt | 5 +- src/bounce_solution/CMakeLists.txt | 5 +- src/gravitational_waves/CMakeLists.txt | 5 +- src/minimizer/CMakeLists.txt | 17 +-- src/minimizer/LibCMAES/CMakeLists.txt | 18 +-- src/minimizer/LibNLOPT/CMakeLists.txt | 23 ++-- src/minimum_tracer/CMakeLists.txt | 5 +- src/models/CMakeLists.txt | 5 +- src/transition_tracer/CMakeLists.txt | 6 +- src/utility/CMakeLists.txt | 9 +- src/utility/asciiplotter/CMakeLists.txt | 6 +- src/utility/spline/CMakeLists.txt | 5 +- standalone/CMakeLists.txt | 47 ++++--- test_package/CMakeLists.txt | 3 +- tools/cmake/CompilerOptions.cmake | 4 +- 17 files changed, 150 insertions(+), 187 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3134e622..f925c3dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif(NOT CMAKE_BUILD_TYPE) -#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") include(LTO) @@ -120,8 +120,6 @@ if(NOT libcmaes_FOUND AND NOT NLopt_FOUND) message(FATAL_ERROR "You need at least libcmaes or NLopt.") endif() - - # -------------------- Coverage # -------------------------------------------------- @@ -160,8 +158,6 @@ endif(EnableCoverage) find_lto(CXX) - - add_subdirectory(src) add_subdirectory(standalone) @@ -175,7 +171,14 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) VERSION ${PACKAGE_VERSION} COMPATIBILITY AnyNewerVersion) - set(ExportList Models Minimizer ThermalFunctions Utility Spline ASCIIPlotter BSMPT_Config) + set(ExportList + Models + Minimizer + ThermalFunctions + Utility + Spline + ASCIIPlotter + BSMPT_Config) if(libcmaes_FOUND) list(APPEND ExportList Minimizer_CMAES) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a036b1e8..7edfdd03 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,24 +3,19 @@ # # SPDX-License-Identifier: GPL-3.0-or-later - -configure_file(${BSMPT_SOURCE_DIR}/include/BSMPT/config.h.in ${BSMPT_BINARY_DIR}/include/BSMPT/config.h) +configure_file(${BSMPT_SOURCE_DIR}/include/BSMPT/config.h.in + ${BSMPT_BINARY_DIR}/include/BSMPT/config.h) add_library(BSMPT_Config INTERFACE) set(header_path ${BSMPT_BINARY_DIR}/include/BSMPT) -target_include_directories(BSMPT_Config INTERFACE - - - - ) +target_include_directories( + BSMPT_Config + INTERFACE + + ) set(header ${header_path}/config.h) set_property(TARGET BSMPT_Config PROPERTY PUBLIC_HEADER ${header}) - -install( - TARGETS BSMPT_Config - PUBLIC_HEADER DESTINATION include/BSMPT -) - +install(TARGETS BSMPT_Config PUBLIC_HEADER DESTINATION include/BSMPT) add_subdirectory(minimizer) add_subdirectory(models) @@ -46,92 +41,92 @@ add_subdirectory(utility/spline) if(BSMPTBuildExecutables) -add_executable(BSMPT prog/BSMPT.cpp) -target_link_libraries(BSMPT Minimizer Models Utility) -target_compile_features(BSMPT PUBLIC cxx_std_17) - -add_executable(VEVEVO prog/VEVEVO.cpp) -target_link_libraries(VEVEVO Minimizer Models Utility) -target_compile_features(VEVEVO PUBLIC cxx_std_17) - -add_executable(NLOVEV prog/NLOVEV.cpp) -target_link_libraries(NLOVEV Minimizer Models Utility) -target_compile_features(NLOVEV PUBLIC cxx_std_17) + add_executable(BSMPT prog/BSMPT.cpp) + target_link_libraries(BSMPT Minimizer Models Utility) + target_compile_features(BSMPT PUBLIC cxx_std_17) -add_executable(CalcCT prog/CalcCT.cpp) -target_link_libraries(CalcCT Models Utility) -target_compile_features(CalcCT PUBLIC cxx_std_17) + add_executable(VEVEVO prog/VEVEVO.cpp) + target_link_libraries(VEVEVO Minimizer Models Utility) + target_compile_features(VEVEVO PUBLIC cxx_std_17) -add_executable(TripleHiggsCouplingsNLO prog/TripleHiggsNLO.cpp) -target_link_libraries(TripleHiggsCouplingsNLO Models Utility) -target_compile_features(TripleHiggsCouplingsNLO PUBLIC cxx_std_17) + add_executable(NLOVEV prog/NLOVEV.cpp) + target_link_libraries(NLOVEV Minimizer Models Utility) + target_compile_features(NLOVEV PUBLIC cxx_std_17) -add_executable(Test prog/Test.cpp) -target_link_libraries(Test Minimizer Models Utility) -target_compile_features(Test PUBLIC cxx_std_17) + add_executable(CalcCT prog/CalcCT.cpp) + target_link_libraries(CalcCT Models Utility) + target_compile_features(CalcCT PUBLIC cxx_std_17) -add_executable(CalcGW prog/CalcGW.cpp) -target_link_libraries(CalcGW Utility GW MinimumTracer TransitionTracer) -target_compile_features(CalcGW PUBLIC cxx_std_14) + add_executable(TripleHiggsCouplingsNLO prog/TripleHiggsNLO.cpp) + target_link_libraries(TripleHiggsCouplingsNLO Models Utility) + target_compile_features(TripleHiggsCouplingsNLO PUBLIC cxx_std_17) -add_executable(CalcTemps prog/CalcTemps.cpp) -target_link_libraries(CalcTemps Utility GW MinimumTracer TransitionTracer) -target_compile_features(CalcTemps PUBLIC cxx_std_14) + add_executable(Test prog/Test.cpp) + target_link_libraries(Test Minimizer Models Utility) + target_compile_features(Test PUBLIC cxx_std_17) -add_executable(MinimaTracer prog/MinimaTracer.cpp) -target_link_libraries(MinimaTracer Minimizer Models Utility MinimumTracer - TransitionTracer) -target_compile_features(MinimaTracer PUBLIC cxx_std_14) + add_executable(CalcGW prog/CalcGW.cpp) + target_link_libraries(CalcGW Utility GW MinimumTracer TransitionTracer) + target_compile_features(CalcGW PUBLIC cxx_std_14) -add_executable(PotPlotter prog/PotPlotter.cpp) -target_link_libraries(PotPlotter Models Utility Minimizer MinimumTracer) -target_compile_features(PotPlotter PUBLIC cxx_std_14) - -if(BSMPTCompileBaryo) - add_executable(CalculateEWBG prog/CalculateEWBG.cpp) - target_link_libraries(CalculateEWBG Minimizer Models Baryo Utility) - target_compile_features(CalculateEWBG PUBLIC cxx_std_17) -else(BSMPTCompileBaryo) - message("CalculateEWBG will not compile as Boost is missing") -endif(BSMPTCompileBaryo) - -if(BSMPTCompileBaryo) - add_executable(PlotEWBG_vw prog/PlotEWBG_vw.cpp) - target_link_libraries(PlotEWBG_vw Minimizer Models Baryo Utility) - target_compile_features(PlotEWBG_vw PUBLIC cxx_std_17) -else(BSMPTCompileBaryo) - message("PlotEWBG_vw will not compile as Boost is missing") -endif(BSMPTCompileBaryo) + add_executable(CalcTemps prog/CalcTemps.cpp) + target_link_libraries(CalcTemps Utility GW MinimumTracer TransitionTracer) + target_compile_features(CalcTemps PUBLIC cxx_std_14) -if(BSMPTCompileBaryo) - add_executable(PlotEWBG_nL prog/PlotEWBG_nL.cpp) - target_link_libraries(PlotEWBG_nL Minimizer Models Baryo Utility) - target_compile_features(PlotEWBG_nL PUBLIC cxx_std_17) -else(BSMPTCompileBaryo) - message("PlotEWBG_nL will not compile as Boost is missing") -endif(BSMPTCompileBaryo) + add_executable(MinimaTracer prog/MinimaTracer.cpp) + target_link_libraries(MinimaTracer Minimizer Models Utility MinimumTracer + TransitionTracer) + target_compile_features(MinimaTracer PUBLIC cxx_std_14) -# ======================= Additional testing -# ==================================== + add_executable(PotPlotter prog/PotPlotter.cpp) + target_link_libraries(PotPlotter Models Utility Minimizer MinimumTracer) + target_compile_features(PotPlotter PUBLIC cxx_std_14) -if(MakeAdditionalTesting) + if(BSMPTCompileBaryo) + add_executable(CalculateEWBG prog/CalculateEWBG.cpp) + target_link_libraries(CalculateEWBG Minimizer Models Baryo Utility) + target_compile_features(CalculateEWBG PUBLIC cxx_std_17) + else(BSMPTCompileBaryo) + message("CalculateEWBG will not compile as Boost is missing") + endif(BSMPTCompileBaryo) if(BSMPTCompileBaryo) - add_executable(CreateMuGrid prog/CreateMuGrid.cpp) - target_link_libraries(CreateMuGrid Minimizer Models Baryo Utility) - target_compile_features(CreateMuGrid PUBLIC cxx_std_17) + add_executable(PlotEWBG_vw prog/PlotEWBG_vw.cpp) + target_link_libraries(PlotEWBG_vw Minimizer Models Baryo Utility) + target_compile_features(PlotEWBG_vw PUBLIC cxx_std_17) else(BSMPTCompileBaryo) - message("CreateMuGrid will not compile as Boost is missing") + message("PlotEWBG_vw will not compile as Boost is missing") endif(BSMPTCompileBaryo) if(BSMPTCompileBaryo) - add_executable(Kfactor_grid prog/Kfactor_grid.cpp) - target_link_libraries(Kfactor_grid Minimizer Models Kfactors Utility) - target_compile_features(Kfactor_grid PUBLIC cxx_std_17) + add_executable(PlotEWBG_nL prog/PlotEWBG_nL.cpp) + target_link_libraries(PlotEWBG_nL Minimizer Models Baryo Utility) + target_compile_features(PlotEWBG_nL PUBLIC cxx_std_17) else(BSMPTCompileBaryo) - message("Kfactor_grid will not compile as Boost is missing") + message("PlotEWBG_nL will not compile as Boost is missing") endif(BSMPTCompileBaryo) -endif(MakeAdditionalTesting) + # ======================= Additional testing + # ==================================== + + if(MakeAdditionalTesting) + + if(BSMPTCompileBaryo) + add_executable(CreateMuGrid prog/CreateMuGrid.cpp) + target_link_libraries(CreateMuGrid Minimizer Models Baryo Utility) + target_compile_features(CreateMuGrid PUBLIC cxx_std_17) + else(BSMPTCompileBaryo) + message("CreateMuGrid will not compile as Boost is missing") + endif(BSMPTCompileBaryo) + + if(BSMPTCompileBaryo) + add_executable(Kfactor_grid prog/Kfactor_grid.cpp) + target_link_libraries(Kfactor_grid Minimizer Models Kfactors Utility) + target_compile_features(Kfactor_grid PUBLIC cxx_std_17) + else(BSMPTCompileBaryo) + message("Kfactor_grid will not compile as Boost is missing") + endif(BSMPTCompileBaryo) + + endif(MakeAdditionalTesting) -endif(BSMPTBuildExecutables) \ No newline at end of file +endif(BSMPTBuildExecutables) diff --git a/src/ThermalFunctions/CMakeLists.txt b/src/ThermalFunctions/CMakeLists.txt index deecc0ef..e6c52666 100644 --- a/src/ThermalFunctions/CMakeLists.txt +++ b/src/ThermalFunctions/CMakeLists.txt @@ -20,7 +20,4 @@ target_compile_features(ThermalFunctions PUBLIC cxx_std_17) set_property(TARGET ThermalFunctions PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS ThermalFunctions - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS ThermalFunctions PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/bounce_solution/CMakeLists.txt b/src/bounce_solution/CMakeLists.txt index f72db0ad..7efd17bc 100644 --- a/src/bounce_solution/CMakeLists.txt +++ b/src/bounce_solution/CMakeLists.txt @@ -16,7 +16,4 @@ target_compile_features(BounceSolution PUBLIC cxx_std_14) set_property(TARGET BounceSolution PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS BounceSolution - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS BounceSolution PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/gravitational_waves/CMakeLists.txt b/src/gravitational_waves/CMakeLists.txt index 9019ad67..d4efe560 100644 --- a/src/gravitational_waves/CMakeLists.txt +++ b/src/gravitational_waves/CMakeLists.txt @@ -17,7 +17,4 @@ target_compile_features(GW PUBLIC cxx_std_17) set_property(TARGET GW PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS GW - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS GW PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimizer/CMakeLists.txt b/src/minimizer/CMakeLists.txt index ab2af286..6d5f7ed6 100644 --- a/src/minimizer/CMakeLists.txt +++ b/src/minimizer/CMakeLists.txt @@ -8,13 +8,13 @@ set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/Minimizer.h ${header_path}/MinimizePlane.h ${header_path}/MinimizeGSL.h) - add_library(Minimizer STATIC) target_link_libraries(Minimizer PUBLIC Eigen3::Eigen GSL::gsl Threads::Threads Utility Models) -target_sources(Minimizer PUBLIC MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp PUBLIC ${header}) - - +target_sources( + Minimizer + PUBLIC MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp + PUBLIC ${header}) if(libcmaes_FOUND) add_subdirectory(LibCMAES) @@ -26,10 +26,6 @@ if(NLopt_FOUND) target_link_libraries(Minimizer PUBLIC Minimizer_NLOPT) endif() - - - - target_include_directories(Minimizer PUBLIC ${BSMPT_SOURCE_DIR}/include ${BSMPT_BINARY_DIR}/include) target_include_directories(Minimizer PUBLIC ${BSMPT_SOURCE_DIR}/include) @@ -37,7 +33,4 @@ target_compile_features(Minimizer PUBLIC cxx_std_17) set_property(TARGET Minimizer PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS Minimizer - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS Minimizer PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt index ed1ddcd3..547be494 100644 --- a/src/minimizer/LibCMAES/CMakeLists.txt +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -12,19 +12,19 @@ target_sources(Minimizer_CMAES INTERFACE MinimizeLibCMAES.cpp ${header}) target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) # target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) -target_link_libraries(Minimizer_CMAES INTERFACE "$") +target_link_libraries(Minimizer_CMAES + INTERFACE "$") if(OpenMP_FOUND) -target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) + target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) endif() -target_include_directories(Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include - ${BSMPT_BINARY_DIR}/include) -target_include_directories(Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include) +target_include_directories( + Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include + ${BSMPT_BINARY_DIR}/include) +target_include_directories(Minimizer_CMAES + INTERFACE ${BSMPT_SOURCE_DIR}/include) target_compile_features(Minimizer_CMAES INTERFACE cxx_std_17) set_property(TARGET Minimizer_CMAES PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS Minimizer_CMAES - PUBLIC_HEADER DESTINATION ${suffix} -) +install(TARGETS Minimizer_CMAES PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimizer/LibNLOPT/CMakeLists.txt b/src/minimizer/LibNLOPT/CMakeLists.txt index 615d4bc7..c5aec26e 100644 --- a/src/minimizer/LibNLOPT/CMakeLists.txt +++ b/src/minimizer/LibNLOPT/CMakeLists.txt @@ -13,20 +13,19 @@ add_library(Minimizer_NLOPT INTERFACE) target_sources(Minimizer_NLOPT INTERFACE ${header} ${src}) target_link_libraries(Minimizer_NLOPT INTERFACE Minimizer) - if(TARGET NLopt::nlopt) - target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt) - else() - target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt_cxx) - endif() +if(TARGET NLopt::nlopt) + target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt) +else() + target_link_libraries(Minimizer_NLOPT INTERFACE NLopt::nlopt_cxx) +endif() -target_include_directories(Minimizer_NLOPT INTERFACE ${BSMPT_SOURCE_DIR}/include - ${BSMPT_BINARY_DIR}/include) -target_include_directories(Minimizer_NLOPT INTERFACE ${BSMPT_SOURCE_DIR}/include) +target_include_directories( + Minimizer_NLOPT INTERFACE ${BSMPT_SOURCE_DIR}/include + ${BSMPT_BINARY_DIR}/include) +target_include_directories(Minimizer_NLOPT + INTERFACE ${BSMPT_SOURCE_DIR}/include) target_compile_features(Minimizer_NLOPT INTERFACE cxx_std_17) set_property(TARGET Minimizer_NLOPT PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS Minimizer_NLOPT - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS Minimizer_NLOPT PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/minimum_tracer/CMakeLists.txt b/src/minimum_tracer/CMakeLists.txt index dc3d9ffa..70fbcbe9 100644 --- a/src/minimum_tracer/CMakeLists.txt +++ b/src/minimum_tracer/CMakeLists.txt @@ -18,7 +18,4 @@ target_compile_features(MinimumTracer PUBLIC cxx_std_17) set_property(TARGET MinimumTracer PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS MinimumTracer - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS MinimumTracer PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/models/CMakeLists.txt b/src/models/CMakeLists.txt index a84e6a04..f70d1402 100644 --- a/src/models/CMakeLists.txt +++ b/src/models/CMakeLists.txt @@ -46,7 +46,4 @@ target_compile_features(Models PUBLIC cxx_std_17) set_property(TARGET Models PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS Models - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS Models PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/transition_tracer/CMakeLists.txt b/src/transition_tracer/CMakeLists.txt index e886b056..0317d3ec 100644 --- a/src/transition_tracer/CMakeLists.txt +++ b/src/transition_tracer/CMakeLists.txt @@ -15,10 +15,6 @@ target_link_libraries(TransitionTracer PUBLIC MinimumTracer BounceSolution GW) target_include_directories(TransitionTracer PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(TransitionTracer PUBLIC cxx_std_14) - set_property(TARGET TransitionTracer PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS TransitionTracer - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS TransitionTracer PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/utility/CMakeLists.txt b/src/utility/CMakeLists.txt index 5a27de00..cebde8aa 100644 --- a/src/utility/CMakeLists.txt +++ b/src/utility/CMakeLists.txt @@ -6,7 +6,9 @@ set(suffix "include/BSMPT/utility") set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header - ${header_path}/utility.h ${header_path}/Logger.h ${header_path}/parser.h + ${header_path}/utility.h + ${header_path}/Logger.h + ${header_path}/parser.h ${header_path}/const_velocity_spline.h ${header_path}/NumericalDerivatives.h ${header_path}/ModelIDs.h @@ -29,7 +31,4 @@ target_link_libraries(Utility PUBLIC ASCIIPlotter Spline GSL::gsl BSMPT_Config) set_property(TARGET Utility PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS Utility - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS Utility PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/utility/asciiplotter/CMakeLists.txt b/src/utility/asciiplotter/CMakeLists.txt index 3039943a..b675ace7 100644 --- a/src/utility/asciiplotter/CMakeLists.txt +++ b/src/utility/asciiplotter/CMakeLists.txt @@ -20,8 +20,4 @@ if(nlohmann_json_FOUND) target_link_libraries(ASCIIPlotter PRIVATE nlohmann_json::nlohmann_json) endif() -install( - TARGETS ASCIIPlotter - PUBLIC_HEADER DESTINATION ${suffix} -) - +install(TARGETS ASCIIPlotter PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/src/utility/spline/CMakeLists.txt b/src/utility/spline/CMakeLists.txt index dc07c296..a977c4af 100644 --- a/src/utility/spline/CMakeLists.txt +++ b/src/utility/spline/CMakeLists.txt @@ -24,7 +24,4 @@ target_compile_definitions(Spline PRIVATE _USE_MATH_DEFINES) set_property(TARGET Spline PROPERTY PUBLIC_HEADER ${header}) -install( - TARGETS Spline - PUBLIC_HEADER DESTINATION ${suffix} -) \ No newline at end of file +install(TARGETS Spline PUBLIC_HEADER DESTINATION ${suffix}) diff --git a/standalone/CMakeLists.txt b/standalone/CMakeLists.txt index 1f98cc9c..ad87674f 100644 --- a/standalone/CMakeLists.txt +++ b/standalone/CMakeLists.txt @@ -5,30 +5,29 @@ if(BSMPTBuildExecutables) -set(STANDALONE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -file(GLOB SOURCE_FILES "*.cpp" CONFIURE_DEPENDS) + set(STANDALONE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + file(GLOB SOURCE_FILES "*.cpp" CONFIURE_DEPENDS) -foreach(file_path ${SOURCE_FILES}) - get_filename_component(filename "${file_path}" NAME) - string(REPLACE ".cpp" "" filename "${filename}") - add_executable("${filename}" "${file_path}") - target_link_libraries( - "${filename}" - PRIVATE Minimizer - MinimumTracer - Models - Utility - TestCompares - ThermalFunctions - BounceSolution - TransitionTracer - GW) - set_target_properties( - "${filename}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY - "${CMAKE_BINARY_DIR}/bin/standalone") + foreach(file_path ${SOURCE_FILES}) + get_filename_component(filename "${file_path}" NAME) + string(REPLACE ".cpp" "" filename "${filename}") + add_executable("${filename}" "${file_path}") + target_link_libraries( + "${filename}" + PRIVATE Minimizer + MinimumTracer + Models + Utility + TestCompares + ThermalFunctions + BounceSolution + TransitionTracer + GW) + set_target_properties( + "${filename}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/bin/standalone") - target_compile_features("${filename}" PUBLIC cxx_std_14) -endforeach() + target_compile_features("${filename}" PUBLIC cxx_std_14) + endforeach() - -endif(BSMPTBuildExecutables) \ No newline at end of file +endif(BSMPTBuildExecutables) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index bbad4815..932ef4e0 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,4 +4,5 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::Models BSMPT::Minimizer ) \ No newline at end of file +target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution + BSMPT::Models BSMPT::Minimizer) diff --git a/tools/cmake/CompilerOptions.cmake b/tools/cmake/CompilerOptions.cmake index d48da3d9..0b475a27 100644 --- a/tools/cmake/CompilerOptions.cmake +++ b/tools/cmake/CompilerOptions.cmake @@ -4,8 +4,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later add_compile_definitions( - $<$,$,$>:_GLIBCXX_USE_CXX11_ABI=1> - ) + $<$,$,$>:_GLIBCXX_USE_CXX11_ABI=1> +) add_compile_options( $<$:-DCOMPILEDEBUG=true> From abd19e2c332c1221e44d1b2963697ca6c6cc039d Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 21:59:19 +0200 Subject: [PATCH 36/69] add cmaes conan file --- Setup.py | 5 ++ conanfile.py | 14 ++++++ test_package/CMakeLists.txt | 5 +- tools/cmake/CMAES.cmake | 2 +- tools/conan/cmaes/conandata.yml | 4 ++ tools/conan/cmaes/conanfile.py | 86 +++++++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 tools/conan/cmaes/conandata.yml create mode 100644 tools/conan/cmaes/conanfile.py diff --git a/Setup.py b/Setup.py index d3953d2a..39f0967f 100644 --- a/Setup.py +++ b/Setup.py @@ -187,6 +187,9 @@ def conan_install_all( build_missing, ) +def create_cmaes(): + cmd = "conan export . --version=0.10.0".split() + subprocess.check_call(cmd, cwd="tools/conan/cmaes") def create(build_missing=False): @@ -259,6 +262,8 @@ def __str__(self): setup_profiles() + create_cmaes() + if opts.create: create(build_missing=opts.build_missing,) else: diff --git a/conanfile.py b/conanfile.py index 35b06426..563e8beb 100644 --- a/conanfile.py +++ b/conanfile.py @@ -68,6 +68,9 @@ def requirements(self): if self.options.UseLibCMAES and self.settings.os != "Windows": self.requires("llvm-openmp/17.0.6", transitive_headers=True) + if self.options.UseLibCMAES: + self.requires("cmaes/0.10.0",transitive_headers=True,transitive_libs=True) + def build_requirements(self): self.tool_requires("cmake/3.29.0") @@ -146,6 +149,15 @@ def package_id(self): def package_info(self): + if self.settings.compiler == "msvc": + openmp_flags = ["-openmp"] + elif self.settings.compiler in ("gcc", "clang"): + openmp_flags = ["-fopenmp"] + elif self.settings.compiler == "apple-clang": + openmp_flags = ["-Xpreprocessor", "-fopenmp"] + else: + openmp_flags = [] + self.cpp_info.components["ASCIIPlotter"].libs = ["ASCIIPlotter"] self.cpp_info.components["ASCIIPlotter"].requires = [ "nlohmann_json::nlohmann_json", @@ -247,6 +259,8 @@ def package_info(self): "Utility", ] self.cpp_info.components["Models"].set_property("cmake_target_name", "BSMPT::Models") + self.cpp_info.components["Models"].exelinkflags = openmp_flags + self.cpp_info.components["Models"].sharedlinkflags = openmp_flags self.cpp_info.components["ThermalFunctions"].libs = ["ThermalFunctions"] self.cpp_info.components["ThermalFunctions"].requires = ["gsl::gsl", "Utility"] diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 932ef4e0..75825c47 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 3.23) project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) +find_package(OpenMP CONFIG QUIET) add_executable(example src/example.cpp) -target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution +target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::cmaes OpenMP::OpenMP_CXX BSMPT::Models BSMPT::Minimizer) + +target_link_libraries(example bsmpt::bsmpt) diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index b7914599..03d1721f 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -15,7 +15,7 @@ if(NOT libcmaes_FOUND) option(LIBCMAES_BUILD_PYTHON OFF) option(LIBCMAES_BUILD_EXAMPLES OFF) option(LIBCMAES_USE_OPENMP OpenMP_FOUND) - option(LIBCMAES_BUILD_SHARED_LIBS OFF) + #option(LIBCMAES_BUILD_SHARED_LIBS OFF) FetchContent_Populate(libcmaes) add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) include(GenerateExportHeader) diff --git a/tools/conan/cmaes/conandata.yml b/tools/conan/cmaes/conandata.yml new file mode 100644 index 00000000..191b7b47 --- /dev/null +++ b/tools/conan/cmaes/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.10.0": + url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" + sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" diff --git a/tools/conan/cmaes/conanfile.py b/tools/conan/cmaes/conanfile.py new file mode 100644 index 00000000..546ede9d --- /dev/null +++ b/tools/conan/cmaes/conanfile.py @@ -0,0 +1,86 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy +import os + +class CmaesConan(ConanFile): + name = "cmaes" + + generators = "CMakeDeps" + + # Optional metadata + license = "LGPLv3" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/CMA-ES/libcmaes" + description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" + topics = ("cmaes", "minimization") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "openmp": [True, False], + "surrog": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "openmp": True, + "surrog": True, + } + + short_paths = True + + def export_sources(self): + export_conandata_patches(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def build_requirements(self): + pass + + def requirements(self): + self.requires("eigen/3.4.0", transitive_headers=True) + if self.options.openmp: + self.requires("llvm-openmp/17.0.6", transitive_headers=True) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self,src_folder="src") + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBCMAES_BUILD_EXAMPLES"] = False + tc.variables["LIBCMAES_BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["LIBCMAES_USE_OPENMP"] = self.options.openmp + tc.variables["LIBCMAES_ENABLE_SURROG"] = self.options.surrog + tc.variables["LIBCMAES_BUILD_PYTHON"] = False + tc.variables["LIBCMAES_BUILD_TESTS"] = False + tc.generate() + + def build(self): + #apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib","pkgconfig")) + rm(self, "*.cmake", os.path.join(self.package_folder, "lib", "cmake", "libcmaes")) + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + + def package_info(self): + self.cpp_info.libs = ["cmaes"] + self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") From ba122c55a2604606ad28690e0a7eaa96569ecb65 Mon Sep 17 00:00:00 2001 From: phbasler Date: Sun, 14 Jul 2024 20:07:19 +0000 Subject: [PATCH 37/69] Automated commit of cmake-format changes. --- test_package/CMakeLists.txt | 10 ++++++++-- tools/cmake/CMAES.cmake | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 75825c47..a69834f7 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -5,7 +5,13 @@ find_package(BSMPT CONFIG REQUIRED) find_package(OpenMP CONFIG QUIET) add_executable(example src/example.cpp) -target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::cmaes OpenMP::OpenMP_CXX - BSMPT::Models BSMPT::Minimizer) +target_link_libraries( + example + BSMPT::Utility + BSMPT::BounceSolution + BSMPT::cmaes + OpenMP::OpenMP_CXX + BSMPT::Models + BSMPT::Minimizer) target_link_libraries(example bsmpt::bsmpt) diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 03d1721f..2c9845d7 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -15,7 +15,7 @@ if(NOT libcmaes_FOUND) option(LIBCMAES_BUILD_PYTHON OFF) option(LIBCMAES_BUILD_EXAMPLES OFF) option(LIBCMAES_USE_OPENMP OpenMP_FOUND) - #option(LIBCMAES_BUILD_SHARED_LIBS OFF) + # option(LIBCMAES_BUILD_SHARED_LIBS OFF) FetchContent_Populate(libcmaes) add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) include(GenerateExportHeader) From b6d8c85bf05bf61a80998593cbeb1db3b745a5d4 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:18:23 +0200 Subject: [PATCH 38/69] remove cmaes through cmake and get it through conan --- .github/workflows/conan.yml | 1 - conanfile.py | 58 +++++++++++++++++++++---------------- tools/cmake/CMAES.cmake | 33 +-------------------- 3 files changed, 34 insertions(+), 58 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 5196c9e3..f71bd229 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -5,7 +5,6 @@ on: branches: - master - main - - feature/create-conan-package pull_request: branches: - master diff --git a/conanfile.py b/conanfile.py index 563e8beb..64fa7391 100644 --- a/conanfile.py +++ b/conanfile.py @@ -14,7 +14,6 @@ class BSMPT(ConanFile): generators = "CMakeDeps" name = "bsmpt" - exports_sources = ( "CMakeLists.txt", @@ -40,7 +39,7 @@ class BSMPT(ConanFile): ], # compile the electroweak baryogenesis for the C2HDM "EnableCoverage": [True, False], # enable code coverage "UseVectorization": [True, False], # use vectorization for the build, - "BuildExecutables": [True,False] + "BuildExecutables": [True, False], } default_options = { "fPIC": True, @@ -51,7 +50,7 @@ class BSMPT(ConanFile): "CompileBaryo": False, "EnableCoverage": False, "UseVectorization": True, - "BuildExecutables": True + "BuildExecutables": True, } def requirements(self): @@ -69,7 +68,7 @@ def requirements(self): self.requires("llvm-openmp/17.0.6", transitive_headers=True) if self.options.UseLibCMAES: - self.requires("cmaes/0.10.0",transitive_headers=True,transitive_libs=True) + self.requires("cmaes/0.10.0", transitive_headers=True, transitive_libs=True) def build_requirements(self): self.tool_requires("cmake/3.29.0") @@ -133,7 +132,7 @@ def validate(self): def config_options(self): if self.settings.os == "Windows": - del self.options.fPIC + del self.options.fPIC def build(self): cmake = CMake(self) @@ -162,7 +161,9 @@ def package_info(self): self.cpp_info.components["ASCIIPlotter"].requires = [ "nlohmann_json::nlohmann_json", ] - self.cpp_info.components["ASCIIPlotter"].set_property("cmake_target_name", "BSMPT::ASCIIPlotter") + self.cpp_info.components["ASCIIPlotter"].set_property( + "cmake_target_name", "BSMPT::ASCIIPlotter" + ) if self.options.CompileBaryo: self.cpp_info.components["ASCIIPlotter"].requires.append( @@ -173,7 +174,9 @@ def package_info(self): self.cpp_info.components["Spline"].requires = [ "nlohmann_json::nlohmann_json", ] - self.cpp_info.components["Spline"].set_property("cmake_target_name", "BSMPT::Spline") + self.cpp_info.components["Spline"].set_property( + "cmake_target_name", "BSMPT::Spline" + ) if self.options.CompileBaryo: self.cpp_info.components["Spline"].requires.append( @@ -187,14 +190,15 @@ def package_info(self): "ASCIIPlotter", "Spline", ] - self.cpp_info.components["Utility"].set_property("cmake_target_name", "BSMPT::Utility") + self.cpp_info.components["Utility"].set_property( + "cmake_target_name", "BSMPT::Utility" + ) if self.options.CompileBaryo: self.cpp_info.components["Utility"].requires.append( "boost::boost", ) - self.cpp_info.components["BounceSolution"].libs = ["BounceSolution"] self.cpp_info.components["BounceSolution"].requires = [ "eigen::eigen", @@ -203,7 +207,9 @@ def package_info(self): "Utility", "MinimumTracer", ] - self.cpp_info.components["BounceSolution"].set_property("cmake_target_name", "BSMPT::BounceSolution") + self.cpp_info.components["BounceSolution"].set_property( + "cmake_target_name", "BSMPT::BounceSolution" + ) self.cpp_info.components["GW"].libs = ["GW"] self.cpp_info.components["GW"].requires = [ @@ -224,22 +230,16 @@ def package_info(self): "Models", # "Minimizer_CMAES" ] - self.cpp_info.components["Minimizer"].set_property("cmake_target_name", "BSMPT::Minimizer") + self.cpp_info.components["Minimizer"].set_property( + "cmake_target_name", "BSMPT::Minimizer" + ) if self.options.UseLibCMAES: - self.cpp_info.components["libcmaes"].libs= ["cmaes"] - self.cpp_info.components["libcmaes"].set_property("cmake_target_name", "BSMPT::cmaes") - self.cpp_info.components["libcmaes"].requires = ["eigen::eigen"] - if self.settings.os != "Windows": - self.cpp_info.components["libcmaes"].requires = ["llvm-openmp::llvm-openmp"] - - self.cpp_info.components["Minimizer"].requires.append("libcmaes") + self.cpp_info.components["Minimizer"].requires.append("libcmaes::cmaes") if self.options.UseNLopt: - self.cpp_info.components["Minimizer"].requires = [ - "nlopt::nlopt", - ] + self.cpp_info.components["Minimizer"].requires.append("nlopt::nlopt") self.cpp_info.components["MinimumTracer"].libs = ["MinimumTracer"] self.cpp_info.components["MinimumTracer"].requires = [ @@ -248,7 +248,9 @@ def package_info(self): "Minimizer", "Utility", ] - self.cpp_info.components["MinimumTracer"].set_property("cmake_target_name", "BSMPT::MinimumTracer") + self.cpp_info.components["MinimumTracer"].set_property( + "cmake_target_name", "BSMPT::MinimumTracer" + ) self.cpp_info.components["Models"].libs = ["Models"] self.cpp_info.components["Models"].requires = [ @@ -258,13 +260,17 @@ def package_info(self): "ThermalFunctions", "Utility", ] - self.cpp_info.components["Models"].set_property("cmake_target_name", "BSMPT::Models") + self.cpp_info.components["Models"].set_property( + "cmake_target_name", "BSMPT::Models" + ) self.cpp_info.components["Models"].exelinkflags = openmp_flags self.cpp_info.components["Models"].sharedlinkflags = openmp_flags self.cpp_info.components["ThermalFunctions"].libs = ["ThermalFunctions"] self.cpp_info.components["ThermalFunctions"].requires = ["gsl::gsl", "Utility"] - self.cpp_info.components["ThermalFunctions"].set_property("cmake_target_name", "BSMPT::ThermalFunctions") + self.cpp_info.components["ThermalFunctions"].set_property( + "cmake_target_name", "BSMPT::ThermalFunctions" + ) self.cpp_info.components["TransitionTracer"].libs = ["TransitionTracer"] self.cpp_info.components["TransitionTracer"].requires = [ @@ -272,4 +278,6 @@ def package_info(self): "MinimumTracer", "GW", ] - self.cpp_info.components["TransitionTracer"].set_property("cmake_target_name", "BSMPT::TransitionTracer") + self.cpp_info.components["TransitionTracer"].set_property( + "cmake_target_name", "BSMPT::TransitionTracer" + ) diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 03d1721f..bf6ec2a1 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -1,34 +1,3 @@ find_package(OpenMP CONFIG QUIET) -find_package(libcmaes 0.10 QUIET) -if(NOT libcmaes_FOUND) - set(BSMPT_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set(BSMPT_CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - set(BSMPT_CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - set(EXPORT_CMAES TRUE) - FetchContent_Declare( - libcmaes - GIT_REPOSITORY https://github.com/CMA-ES/libcmaes.git - GIT_TAG v0.10) - FetchContent_GetProperties(libcmaes) - if(NOT libcmaes_POPULATED) - option(LIBCMAES_BUILD_TESTS OFF) - option(LIBCMAES_BUILD_PYTHON OFF) - option(LIBCMAES_BUILD_EXAMPLES OFF) - option(LIBCMAES_USE_OPENMP OpenMP_FOUND) - #option(LIBCMAES_BUILD_SHARED_LIBS OFF) - FetchContent_Populate(libcmaes) - add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) - include(GenerateExportHeader) - generate_export_header( - cmaes EXPORT_FILE_NAME - ${libcmaes_SOURCE_DIR}/include/libcmaes/cmaes_export.h) - message(STATUS ${libcmaes_SOURCE_DIR}) - set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs} - "${libcmaes_SOURCE_DIR}/*") - endif() +find_package(cmaes 0.10 REQUIRED) - set(libcmaes_FOUND TRUE) -else() - set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs} - "${libcmaes_ROOT_DIR}/*") -endif() From 642a4359a980302cea1ff2933f8970e2ab91358b Mon Sep 17 00:00:00 2001 From: phbasler Date: Sun, 14 Jul 2024 20:21:00 +0000 Subject: [PATCH 39/69] Automated commit of cmake-format changes. --- tools/cmake/CMAES.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index bf6ec2a1..3ace4bc8 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -1,3 +1,2 @@ find_package(OpenMP CONFIG QUIET) find_package(cmaes 0.10 REQUIRED) - From 2aecd0688c67debc6d0a2891c6069475dd5c0506 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:38:56 +0200 Subject: [PATCH 40/69] runs on linux --- conanfile.py | 8 ++++---- test_package/CMakeLists.txt | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/conanfile.py b/conanfile.py index 64fa7391..b8e1d950 100644 --- a/conanfile.py +++ b/conanfile.py @@ -64,8 +64,8 @@ def requirements(self): if self.options.UseNLopt: self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) - if self.options.UseLibCMAES and self.settings.os != "Windows": - self.requires("llvm-openmp/17.0.6", transitive_headers=True) + #if self.options.UseLibCMAES and self.settings.os != "Windows": + # self.requires("llvm-openmp/17.0.6", transitive_headers=True) if self.options.UseLibCMAES: self.requires("cmaes/0.10.0", transitive_headers=True, transitive_libs=True) @@ -227,7 +227,7 @@ def package_info(self): "gsl::gsl", # "Threads::Threads", "Utility", - "Models", + # "Models", # "Minimizer_CMAES" ] self.cpp_info.components["Minimizer"].set_property( @@ -235,7 +235,7 @@ def package_info(self): ) if self.options.UseLibCMAES: - self.cpp_info.components["Minimizer"].requires.append("libcmaes::cmaes") + self.cpp_info.components["Minimizer"].requires.append("cmaes::cmaes") if self.options.UseNLopt: diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index a69834f7..e00ad4c4 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -2,16 +2,12 @@ cmake_minimum_required(VERSION 3.23) project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) -find_package(OpenMP CONFIG QUIET) add_executable(example src/example.cpp) target_link_libraries( example BSMPT::Utility BSMPT::BounceSolution - BSMPT::cmaes - OpenMP::OpenMP_CXX BSMPT::Models BSMPT::Minimizer) -target_link_libraries(example bsmpt::bsmpt) From 4426bf2554424bf9dbf1aa42d1f42f62591c0fd2 Mon Sep 17 00:00:00 2001 From: phbasler Date: Sun, 14 Jul 2024 20:39:34 +0000 Subject: [PATCH 41/69] Automated commit of cmake-format changes. --- test_package/CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index e00ad4c4..932ef4e0 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -4,10 +4,5 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) add_executable(example src/example.cpp) -target_link_libraries( - example - BSMPT::Utility - BSMPT::BounceSolution - BSMPT::Models - BSMPT::Minimizer) - +target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution + BSMPT::Models BSMPT::Minimizer) From c7c9549f614ba30d79e626f5517f30e853513ee0 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:50:15 +0200 Subject: [PATCH 42/69] adjust cmaes conan file to get openmp through compiler flags --- tools/conan/cmaes/conanfile.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/conan/cmaes/conanfile.py b/tools/conan/cmaes/conanfile.py index 546ede9d..0505e5df 100644 --- a/tools/conan/cmaes/conanfile.py +++ b/tools/conan/cmaes/conanfile.py @@ -43,8 +43,8 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp: - self.requires("llvm-openmp/17.0.6", transitive_headers=True) + # if self.options.openmp: + # self.requires("llvm-openmp/17.0.6", transitive_headers=True) def config_options(self): if self.settings.os == "Windows": @@ -84,3 +84,15 @@ def package(self): def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") + + if self.settings.compiler == "msvc": + openmp_flags = ["-openmp"] + elif self.settings.compiler in ("gcc", "clang"): + openmp_flags = ["-fopenmp"] + elif self.settings.compiler == "apple-clang": + openmp_flags = ["-Xpreprocessor", "-fopenmp"] + else: + openmp_flags = [] + + self.cpp_info.exelinkflags = openmp_flags + self.cpp_info.sharedlinkflags = openmp_flags From 85365c5b0eec6257ac99bd9d7937499ba95bacc7 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:56:35 +0200 Subject: [PATCH 43/69] readd package to cmaes --- tools/conan/cmaes/conanfile.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/tools/conan/cmaes/conanfile.py b/tools/conan/cmaes/conanfile.py index 0505e5df..6d2097be 100644 --- a/tools/conan/cmaes/conanfile.py +++ b/tools/conan/cmaes/conanfile.py @@ -43,8 +43,8 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - # if self.options.openmp: - # self.requires("llvm-openmp/17.0.6", transitive_headers=True) + if self.options.openmp: + self.requires("llvm-openmp/17.0.6", transitive_headers=True) def config_options(self): if self.settings.os == "Windows": @@ -85,14 +85,3 @@ def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") - if self.settings.compiler == "msvc": - openmp_flags = ["-openmp"] - elif self.settings.compiler in ("gcc", "clang"): - openmp_flags = ["-fopenmp"] - elif self.settings.compiler == "apple-clang": - openmp_flags = ["-Xpreprocessor", "-fopenmp"] - else: - openmp_flags = [] - - self.cpp_info.exelinkflags = openmp_flags - self.cpp_info.sharedlinkflags = openmp_flags From ffdeaad126d2d84d6e2dcc9b3e84baddaa94e0ad Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:59:45 +0200 Subject: [PATCH 44/69] dont use openmp in cmaes on windows --- conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conanfile.py b/conanfile.py index b8e1d950..be788c80 100644 --- a/conanfile.py +++ b/conanfile.py @@ -142,6 +142,10 @@ def build(self): def package(self): cmake = CMake(self) cmake.install() + + def configure(self): + if self.settings.os == "Windows": + self.options["cmaes"].openmp = False def package_id(self): del self.info.options.EnableTests From fb5ab3d012d40f06038a0efc73643e790cb74206 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 23:16:06 +0200 Subject: [PATCH 45/69] appy patch for windows cmaes --- tools/conan/cmaes/conandata.yml | 3 ++ tools/conan/cmaes/conanfile.py | 4 +-- tools/conan/cmaes/patches/patch.diff | 52 ++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tools/conan/cmaes/patches/patch.diff diff --git a/tools/conan/cmaes/conandata.yml b/tools/conan/cmaes/conandata.yml index 191b7b47..1afc856c 100644 --- a/tools/conan/cmaes/conandata.yml +++ b/tools/conan/cmaes/conandata.yml @@ -2,3 +2,6 @@ sources: "0.10.0": url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" +patches: + "0.10.0": + - patch_file: "patches/patch.diff" diff --git a/tools/conan/cmaes/conanfile.py b/tools/conan/cmaes/conanfile.py index 6d2097be..f304adc0 100644 --- a/tools/conan/cmaes/conanfile.py +++ b/tools/conan/cmaes/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy +from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches import os class CmaesConan(ConanFile): @@ -68,7 +68,7 @@ def generate(self): tc.generate() def build(self): - #apply_conandata_patches(self) + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff new file mode 100644 index 00000000..c8622cca --- /dev/null +++ b/tools/conan/cmaes/patches/patch.diff @@ -0,0 +1,52 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4a38212..0d6a968 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,9 +6,11 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") + endif () + ++if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "-Wall -Wextra") + set(CMAKE_CXX_FLAGS_DEBUG "-g") + set(CMAKE_CXX_FLAGS_RELEASE "-O3") ++endif() + + list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + +@@ -152,9 +154,7 @@ if (NOT MSVC) + set (libdir ${INSTALL_LIB_DIR}) + set (includedir ${INSTALL_INCLUDE_DIR}) + set (VERSION ${LIBCMAES_VERSION_STRING}) +- configure_file (libcmaes.pc.in libcmaes.pc @ONLY) +- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmaes.pc +- DESTINATION ${RELATIVE_INSTALL_LIB_DIR}/pkgconfig) ++ + endif () + + # ---------- subdirectories ---------- +@@ -174,23 +174,4 @@ endif () + # ------------ export ------------ + add_library (libcmaes::cmaes ALIAS cmaes) + +-include (CMakePackageConfigHelpers) +-write_basic_package_version_file ( +- libcmaesConfigVersion.cmake VERSION ${PACKAGE_VERSION} +- COMPATIBILITY AnyNewerVersion) +- +-# export target to build directory +-export (TARGETS cmaes NAMESPACE libcmaes:: FILE libcmaesTargets.cmake) +-# export target on install +-install ( +- EXPORT libcmaesTargets +- FILE libcmaesTargets.cmake +- NAMESPACE libcmaes:: +- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) +- +-configure_file (libcmaesConfig.cmake.in libcmaesConfig.cmake @ONLY) +-install ( +- FILES "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfig.cmake" +- "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfigVersion.cmake" +- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindEigen3.cmake" +- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) ++ From e729af1262b6fd3341a1862fbd402111145851a3 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 23:21:02 +0200 Subject: [PATCH 46/69] remove windows to check if mac works --- .github/workflows/conan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index f71bd229..1ef5662d 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -20,7 +20,7 @@ jobs: conan: strategy: matrix: - os: [ ubuntu-latest, windows-latest, macos-latest] + os: [ ubuntu-latest, macos-latest] #, windows-latest runs-on: ${{matrix.os}} if: "!contains(github.event.head_commit.message, 'skip-ci')" From eeb3ea65fd5513a1ccd0acd2634395f6db393f8b Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 14 Jul 2024 23:31:40 +0200 Subject: [PATCH 47/69] enable windows again --- .github/workflows/conan.yml | 2 +- tools/conan/cmaes/patches/patch.diff | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 1ef5662d..61a50dd7 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -20,7 +20,7 @@ jobs: conan: strategy: matrix: - os: [ ubuntu-latest, macos-latest] #, windows-latest + os: [ ubuntu-latest, macos-latest, windows-latest] runs-on: ${{matrix.os}} if: "!contains(github.event.head_commit.message, 'skip-ci')" diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff index c8622cca..9e62df19 100644 --- a/tools/conan/cmaes/patches/patch.diff +++ b/tools/conan/cmaes/patches/patch.diff @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4a38212..0d6a968 100644 +index 4a38212..ca76bdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -6,9 +6,11 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) +@@ -6,9 +6,16 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") endif () @@ -10,11 +10,16 @@ index 4a38212..0d6a968 100644 set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") ++endif() ++ ++if(MSVC) ++add_compile_options(/wd4244) ++add_compile_options(/wd4267) +endif() list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -@@ -152,9 +154,7 @@ if (NOT MSVC) +@@ -152,9 +159,7 @@ if (NOT MSVC) set (libdir ${INSTALL_LIB_DIR}) set (includedir ${INSTALL_INCLUDE_DIR}) set (VERSION ${LIBCMAES_VERSION_STRING}) @@ -25,7 +30,7 @@ index 4a38212..0d6a968 100644 endif () # ---------- subdirectories ---------- -@@ -174,23 +174,4 @@ endif () +@@ -174,23 +179,4 @@ endif () # ------------ export ------------ add_library (libcmaes::cmaes ALIAS cmaes) From c14caf9f82f0b877607b69794ea79875135afda6 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:05:05 +0200 Subject: [PATCH 48/69] Apply compiler options from PR --- tools/conan/cmaes/patches/patch.diff | 58 +++++----------------------- 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff index 9e62df19..10c01b4c 100644 --- a/tools/conan/cmaes/patches/patch.diff +++ b/tools/conan/cmaes/patches/patch.diff @@ -1,57 +1,19 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4a38212..ca76bdd 100644 +index 4a38212..dccfea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -6,9 +6,16 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) +@@ -6,12 +6,10 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") endif () -+if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "-Wall -Wextra") - set(CMAKE_CXX_FLAGS_DEBUG "-g") - set(CMAKE_CXX_FLAGS_RELEASE "-O3") -+endif() -+ -+if(MSVC) -+add_compile_options(/wd4244) -+add_compile_options(/wd4267) -+endif() - +-set(CMAKE_CXX_FLAGS "-Wall -Wextra") +-set(CMAKE_CXX_FLAGS_DEBUG "-g") +-set(CMAKE_CXX_FLAGS_RELEASE "-O3") +- list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -@@ -152,9 +159,7 @@ if (NOT MSVC) - set (libdir ${INSTALL_LIB_DIR}) - set (includedir ${INSTALL_INCLUDE_DIR}) - set (VERSION ${LIBCMAES_VERSION_STRING}) -- configure_file (libcmaes.pc.in libcmaes.pc @ONLY) -- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmaes.pc -- DESTINATION ${RELATIVE_INSTALL_LIB_DIR}/pkgconfig) -+ - endif () - - # ---------- subdirectories ---------- -@@ -174,23 +179,4 @@ endif () - # ------------ export ------------ - add_library (libcmaes::cmaes ALIAS cmaes) - --include (CMakePackageConfigHelpers) --write_basic_package_version_file ( -- libcmaesConfigVersion.cmake VERSION ${PACKAGE_VERSION} -- COMPATIBILITY AnyNewerVersion) -- --# export target to build directory --export (TARGETS cmaes NAMESPACE libcmaes:: FILE libcmaesTargets.cmake) --# export target on install --install ( -- EXPORT libcmaesTargets -- FILE libcmaesTargets.cmake -- NAMESPACE libcmaes:: -- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) -- --configure_file (libcmaesConfig.cmake.in libcmaesConfig.cmake @ONLY) --install ( -- FILES "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfig.cmake" -- "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfigVersion.cmake" -- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindEigen3.cmake" -- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) ++include(CompilerOptions) + + set (LIBCMAES_TOP_LEVEL NO) + if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + set (LIBCMAES_TOP_LEVEL YES) From ea330131e2a17696182af9e7f41a07fdd89cd82e Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:13:21 +0200 Subject: [PATCH 49/69] Fix patchfile to include new file --- tools/conan/cmaes/patches/patch.diff | 97 ++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff index 10c01b4c..b93e7b90 100644 --- a/tools/conan/cmaes/patches/patch.diff +++ b/tools/conan/cmaes/patches/patch.diff @@ -17,3 +17,100 @@ index 4a38212..dccfea4 100644 set (LIBCMAES_TOP_LEVEL NO) if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) set (LIBCMAES_TOP_LEVEL YES) +diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake +new file mode 100644 +index 0000000..af4f716 +--- /dev/null ++++ b/cmake/CompilerOptions.cmake +@@ -0,0 +1,91 @@ ++ ++set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} -Wall" ++) ++set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} -Wall ") ++ ++if(CMAKE_COMPILER_IS_GNUCXX) ++ set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} -Wextra") ++ set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wextra") ++endif(CMAKE_COMPILER_IS_GNUCXX) ++ ++if (MSVC) ++ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_USE_MATH_DEFINES" ) ++ ++ set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} /permissive- /bigobj /w44101") ++ ++ set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} /permissive- /bigobj /Ox /w44101") ++ ++ set(MSVC_DISABLED_WARNINGS_LIST ++ "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not ++ # explicitly handled by a case label ++ # Disable this because it flags even when there is a default. ++ "C4068" ++ "C4100" # 'exarg' : unreferenced formal parameter ++ "C4127" # conditional expression is constant ++ "C4200" # nonstandard extension used : zero-sized array in ++ # struct/union. ++ "C4204" # nonstandard extension used: non-constant aggregate initializer ++ "C4221" # nonstandard extension used : 'identifier' : cannot be ++ # initialized using address of automatic variable ++ "C4242" # 'function' : conversion from 'int' to 'uint8_t', ++ # possible loss of data ++ "C4244" # 'function' : conversion from 'int' to 'uint8_t', ++ # possible loss of data ++ "C4245" # 'initializing' : conversion from 'long' to ++ # 'unsigned long', signed/unsigned mismatch ++ "C4251" ++ "C4267" # conversion from 'size_t' to 'int', possible loss of data ++ "C4275" ++ "C4355" ++ "C4371" # layout of class may have changed from a previous version of the ++ # compiler due to better packing of member '...' ++ "C4388" # signed/unsigned mismatch ++ "C4296" # '>=' : expression is always true ++ "C4350" # behavior change: 'std::_Wrap_alloc...' ++ "C4365" # '=' : conversion from 'size_t' to 'int', ++ # signed/unsigned mismatch ++ "C4389" # '!=' : signed/unsigned mismatch ++ "C4464" # relative include path contains '..' ++ "C4510" # 'argument' : default constructor could not be generated ++ "C4571" ++ "C4512" # 'argument' : assignment operator could not be generated ++ "C4514" # 'function': unreferenced inline function has been removed ++ "C4548" # expression before comma has no effect; expected expression with ++ # side-effect" caused by FD_* macros. ++ "C4610" # struct 'argument' can never be instantiated - user defined ++ # constructor required. ++ "C4619" ++ "C4623" # default constructor was implicitly defined as deleted ++ "C4625" # copy constructor could not be generated because a base class ++ # copy constructor is inaccessible or deleted ++ "C4626" # assignment operator could not be generated because a base class ++ # assignment operator is inaccessible or deleted ++ "C4643" ++ "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with ++ # '0' for 'directives' ++ # Disable this because GTest uses it everywhere. ++ "C4706" # assignment within conditional expression ++ "C4710" # 'function': function not inlined ++ "C4711" # function 'function' selected for inline expansion ++ "C4800" # 'int' : forcing value to bool 'true' or 'false' ++ # (performance warning) ++ "C4820" # 'bytes' bytes padding added after construct 'member_name' ++ "C4868" ++ "C4996" ++ "C5026" # move constructor was implicitly defined as deleted ++ "C5027" # move assignment operator was implicitly defined as deleted ++ "C5031" ++ "C5039" ++ "C5045" ++ ) ++ string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR ++ ${MSVC_DISABLED_WARNINGS_LIST}) ++ ++ set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") ++ endif() From 52388eb36357ac49818794e04db09d40a4fec97e Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:20:58 +0200 Subject: [PATCH 50/69] include eigen fix --- tools/conan/cmaes/patches/patch.diff | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff index b93e7b90..ba728f3d 100644 --- a/tools/conan/cmaes/patches/patch.diff +++ b/tools/conan/cmaes/patches/patch.diff @@ -114,3 +114,29 @@ index 0000000..af4f716 + + set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") + endif() +diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h +index fb8b11d..6a6943b 100644 +--- a/include/libcmaes/eigenmvn.h ++++ b/include/libcmaes/eigenmvn.h +@@ -58,7 +58,20 @@ public: + static std::mt19937 rng; // The uniform pseudo-random algorithm + mutable std::normal_distribution norm; // gaussian combinator + +- EIGEN_EMPTY_STRUCT_CTOR(scalar_normal_dist_op) ++ scalar_normal_dist_op() = default; ++ scalar_normal_dist_op(const scalar_normal_dist_op& other) ++ : norm{other.norm} ++ { ++ rng = other.rng; ++ }; ++ scalar_normal_dist_op &operator=(const scalar_normal_dist_op &other) { ++ if(this != &other) ++ { ++ scalar_normal_dist_op temp(other); ++ swap(temp); ++ } ++ return *this; ++ }; + + scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) + { From 06bab61ccc286c93059033a54b0d3fab93d0764f Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:40:43 +0200 Subject: [PATCH 51/69] fix test_package build on windows --- conanfile.py | 5 +---- test_package/CMakeLists.txt | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index be788c80..4a6ffddf 100644 --- a/conanfile.py +++ b/conanfile.py @@ -2,7 +2,7 @@ from conan.tools.system.package_manager import Apt from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import load, update_conandata +from conan.tools.files import load from conan.tools.scm import Git import os, re @@ -64,9 +64,6 @@ def requirements(self): if self.options.UseNLopt: self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) - #if self.options.UseLibCMAES and self.settings.os != "Windows": - # self.requires("llvm-openmp/17.0.6", transitive_headers=True) - if self.options.UseLibCMAES: self.requires("cmaes/0.10.0", transitive_headers=True, transitive_libs=True) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 932ef4e0..309aeea4 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -3,6 +3,13 @@ project(PackageTest CXX) find_package(BSMPT CONFIG REQUIRED) +add_compile_options( + $<$:/permissive-> + $<$,$>:/bigobj> + $<$:/w44101> + $<$,$>:/Ox>) + add_executable(example src/example.cpp) target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::Models BSMPT::Minimizer) + From 688feb9b369429530014cc9419b16bf8388d168d Mon Sep 17 00:00:00 2001 From: phbasler Date: Mon, 15 Jul 2024 04:41:21 +0000 Subject: [PATCH 52/69] Automated commit of cmake-format changes. --- test_package/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 309aeea4..77e9b8bd 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -12,4 +12,3 @@ add_compile_options( add_executable(example src/example.cpp) target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::Models BSMPT::Minimizer) - From fec0df123d01e86e12dbf4e3569d82a9c76ab5d2 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 07:11:25 +0200 Subject: [PATCH 53/69] Only trigger linters on non draft and allow workflows from those commits --- .github/workflows/cmake-format-linter.yml | 12 +++++++++++- .github/workflows/cpp-linter.yml | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-format-linter.yml b/.github/workflows/cmake-format-linter.yml index ee9073ae..fc88b643 100644 --- a/.github/workflows/cmake-format-linter.yml +++ b/.github/workflows/cmake-format-linter.yml @@ -2,7 +2,14 @@ name: Run cmake-format linter on: pull_request: - branches: [ master, develop ] + branches: + - master + - develop + types: + - opened + - reopened + - synchronize + - ready_for_review concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -10,11 +17,14 @@ concurrency: jobs: build: + if: github.event_name == 'pull_request' && github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ssh-key: ${{secrets.DEPLOY_KEY}} - name: Format CMake files id: cmake-format diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 50b092f2..243812dc 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -2,7 +2,13 @@ name: cpp-linter on: pull_request: - branches: [master] + branches: + - master + types: + - opened + - reopened + - synchronize + - ready_for_review concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -10,12 +16,14 @@ concurrency: jobs: cpp-linter: + if: github.event_name == 'pull_request' && github.event.pull_request.draft == false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.head_ref }} + ssh-key: ${{secrets.DEPLOY_KEY}} - name: Install clang-format if: inputs.apply_clang_format From 035d3ce331656e82bd10cef4dbfaf99884d5a322 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 07:28:57 +0200 Subject: [PATCH 54/69] build cmaes if build-missing is not chosen --- Setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Setup.py b/Setup.py index 39f0967f..a76f46da 100644 --- a/Setup.py +++ b/Setup.py @@ -155,6 +155,8 @@ def conan_install(profile, additional_options=[], build_missing=False): if build_missing: cmd += ["--build=missing"] + else: + cmd += ["--build=cmaes/0.10.0"] subprocess.check_call(cmd) From 1f79267bfc6d6e6332608691c3c641262066c0a9 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Tue, 16 Jul 2024 07:11:15 +0200 Subject: [PATCH 55/69] fix cmaes_found --- CMakeLists.txt | 4 ++-- include/BSMPT/config.h.in | 2 +- include/BSMPT/minimizer/Minimizer.h | 2 +- src/minimizer/CMakeLists.txt | 2 +- src/minimizer/LibCMAES/CMakeLists.txt | 2 +- src/minimizer/MinimizePlane.cpp | 4 ++-- src/minimizer/Minimizer.cpp | 8 ++++---- tools/cmake/BSMPTConfig.cmake.in | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f925c3dd..8a47b176 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,7 +116,7 @@ if(UseNLopt) endif(UseNLopt) -if(NOT libcmaes_FOUND AND NOT NLopt_FOUND) +if(NOT cmaes_FOUND AND NOT NLopt_FOUND) message(FATAL_ERROR "You need at least libcmaes or NLopt.") endif() @@ -179,7 +179,7 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) Spline ASCIIPlotter BSMPT_Config) - if(libcmaes_FOUND) + if(cmaes_FOUND) list(APPEND ExportList Minimizer_CMAES) endif() if(NLopt_FOUND) diff --git a/include/BSMPT/config.h.in b/include/BSMPT/config.h.in index 71fd83d2..807ded9e 100644 --- a/include/BSMPT/config.h.in +++ b/include/BSMPT/config.h.in @@ -1,6 +1,6 @@ #pragma once -#cmakedefine libcmaes_FOUND +#cmakedefine cmaes_FOUND #cmakedefine NLopt_FOUND #cmakedefine Boost_FOUND #cmakedefine nlohmann_json_FOUND diff --git a/include/BSMPT/minimizer/Minimizer.h b/include/BSMPT/minimizer/Minimizer.h index a9c1dbec..d00ecf43 100644 --- a/include/BSMPT/minimizer/Minimizer.h +++ b/include/BSMPT/minimizer/Minimizer.h @@ -33,7 +33,7 @@ const bool UseGSLDefault = true; /** * @brief UseLibCMAESDefault Use the Libcmaes minimizer in the default settings */ -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND const bool UseLibCMAESDefault = true; #else const bool UseLibCMAESDefault = false; diff --git a/src/minimizer/CMakeLists.txt b/src/minimizer/CMakeLists.txt index 6d5f7ed6..db785af4 100644 --- a/src/minimizer/CMakeLists.txt +++ b/src/minimizer/CMakeLists.txt @@ -16,7 +16,7 @@ target_sources( PUBLIC MinimizeGSL.cpp Minimizer.cpp MinimizePlane.cpp PUBLIC ${header}) -if(libcmaes_FOUND) +if(cmaes_FOUND) add_subdirectory(LibCMAES) target_link_libraries(Minimizer PUBLIC Minimizer_CMAES) endif() diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt index 547be494..b24b2e4f 100644 --- a/src/minimizer/LibCMAES/CMakeLists.txt +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) # target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) target_link_libraries(Minimizer_CMAES - INTERFACE "$") + INTERFACE libcmaes::cmaes) if(OpenMP_FOUND) target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) endif() diff --git a/src/minimizer/MinimizePlane.cpp b/src/minimizer/MinimizePlane.cpp index f0969ceb..9b13e075 100644 --- a/src/minimizer/MinimizePlane.cpp +++ b/src/minimizer/MinimizePlane.cpp @@ -26,7 +26,7 @@ #include -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND #include #endif @@ -172,7 +172,7 @@ MinimizePlane(const std::vector &basepoint, Minima.push_back(GSLResult.Minimum); } -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND if (UseMinimizer.UseCMAES and modelPointer->get_nVEV() >= 3) { std::vector startCMAES(params.nVEV - 1); diff --git a/src/minimizer/Minimizer.cpp b/src/minimizer/Minimizer.cpp index 09989da6..cb40e188 100644 --- a/src/minimizer/Minimizer.cpp +++ b/src/minimizer/Minimizer.cpp @@ -24,7 +24,7 @@ #include -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND #include #endif @@ -69,7 +69,7 @@ MinimizersToUse GetMinimizers(int WhichMinimizer) WhichMinimizer /= 2; bool UseNLopt = (WhichMinimizer % 2 != 0); -#ifndef libcmaes_FOUND +#ifndef cmaes_FOUND UseCMAES = false; #endif @@ -153,7 +153,7 @@ Minimize_gen_all(const std::shared_ptr &modelPointer, } } } -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND std::thread thread_CMAES; LibCMAES::LibCMAESReturn LibCMAES; if (UseMinimizer.UseCMAES) @@ -210,7 +210,7 @@ Minimize_gen_all(const std::shared_ptr &modelPointer, } #endif -#ifdef libcmaes_FOUND +#ifdef cmaes_FOUND if (UseMultithreading and thread_CMAES.joinable()) { Logger::Write(LoggingLevel::MinimizerDetailed, "Waiting for CMAES Thread"); diff --git a/tools/cmake/BSMPTConfig.cmake.in b/tools/cmake/BSMPTConfig.cmake.in index 18bac8e9..7a30afe1 100644 --- a/tools/cmake/BSMPTConfig.cmake.in +++ b/tools/cmake/BSMPTConfig.cmake.in @@ -14,9 +14,9 @@ find_dependency(GSL @GSL_VERSION@) find_dependency(OpenMP @OpenMP_CXX_VERSION@) find_dependency(Threads @Threads_VERSION@) -if(@libcmaes_FOUND@ AND NOT @EXPORT_CMAES@) +if(@cmaes_FOUND@ AND NOT @EXPORT_CMAES@) find_dependency(libcmaes) -endif(@libcmaes_FOUND@ AND NOT @EXPORT_CMAES@) +endif(@cmaes_FOUND@ AND NOT @EXPORT_CMAES@) if(@NLopt_FOUND@) find_dependency(NLopt @NLopt_VERSION@) From 37676f7b4745ff954c5e43f202a2bd5ebf77b8f5 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Wed, 17 Jul 2024 06:17:48 +0200 Subject: [PATCH 56/69] add missing $ --- .gitignore | 1 + conanfile.py | 1 + src/CMakeLists.txt | 7 ++++--- src/minimizer/LibCMAES/CMakeLists.txt | 1 - src/utility/asciiplotter/asciiplotter.cpp | 11 +++++++---- tools/cmake/BSMPTConfig.cmake.in | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 571b3146..828cdda3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ CMakeUserPresets.json __pycache__/* test_package/build/ +CMakeLists.txt.user diff --git a/conanfile.py b/conanfile.py index 4a6ffddf..d6f76658 100644 --- a/conanfile.py +++ b/conanfile.py @@ -51,6 +51,7 @@ class BSMPT(ConanFile): "EnableCoverage": False, "UseVectorization": True, "BuildExecutables": True, + "cmaes/*:shared": True } def requirements(self): diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7edfdd03..0bccee9e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,13 +5,14 @@ configure_file(${BSMPT_SOURCE_DIR}/include/BSMPT/config.h.in ${BSMPT_BINARY_DIR}/include/BSMPT/config.h) + add_library(BSMPT_Config INTERFACE) set(header_path ${BSMPT_BINARY_DIR}/include/BSMPT) target_include_directories( BSMPT_Config - INTERFACE - - ) + INTERFACE $ + $ + $) set(header ${header_path}/config.h) set_property(TARGET BSMPT_Config PROPERTY PUBLIC_HEADER ${header}) diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt index b24b2e4f..32cb1ac9 100644 --- a/src/minimizer/LibCMAES/CMakeLists.txt +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -11,7 +11,6 @@ add_library(Minimizer_CMAES INTERFACE) target_sources(Minimizer_CMAES INTERFACE MinimizeLibCMAES.cpp ${header}) target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) -# target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) if(OpenMP_FOUND) diff --git a/src/utility/asciiplotter/asciiplotter.cpp b/src/utility/asciiplotter/asciiplotter.cpp index 10651315..50a71c0e 100644 --- a/src/utility/asciiplotter/asciiplotter.cpp +++ b/src/utility/asciiplotter/asciiplotter.cpp @@ -26,7 +26,9 @@ SOFTWARE. using namespace std; -int max(vector data) +namespace +{ +int max(const vector &data) { int xmax = data[0]; for (std::size_t i = 1; i < sizeof(data); i++) @@ -39,7 +41,7 @@ int max(vector data) return xmax; } -int min(vector data) +int min(const vector &data) { int xmin = data[0]; for (std::size_t i = 1; i < data.size(); i++) @@ -52,7 +54,7 @@ int min(vector data) return xmin; } -double max(vector data) +double max(const vector &data) { double xmax = data[0]; for (std::size_t i = 1; i < data.size(); i++) @@ -65,7 +67,7 @@ double max(vector data) return xmax; } -double min(vector data) +double min(const vector &data) { double xmin = data[0]; for (std::size_t i = 1; i < data.size(); i++) @@ -169,6 +171,7 @@ resample(vector xdata, vector ydata, int newlength) } } +} // namespace AsciiPlotter::AsciiPlotter() { _title = ""; diff --git a/tools/cmake/BSMPTConfig.cmake.in b/tools/cmake/BSMPTConfig.cmake.in index 7a30afe1..6d7a623b 100644 --- a/tools/cmake/BSMPTConfig.cmake.in +++ b/tools/cmake/BSMPTConfig.cmake.in @@ -15,7 +15,7 @@ find_dependency(OpenMP @OpenMP_CXX_VERSION@) find_dependency(Threads @Threads_VERSION@) if(@cmaes_FOUND@ AND NOT @EXPORT_CMAES@) - find_dependency(libcmaes) + #find_dependency(cmaes) endif(@cmaes_FOUND@ AND NOT @EXPORT_CMAES@) if(@NLopt_FOUND@) From dd28538f7359c0bda5ec45ec515c76f798a65cd1 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Thu, 18 Jul 2024 21:06:36 +0200 Subject: [PATCH 57/69] Add clang profiles --- CMakeLists.txt | 3 ++ Setup.py | 45 +++++++++++++------- conanfile.py | 4 +- profiles/BSMPT/linux-debug-x86_64-clang-14 | 9 ++++ profiles/BSMPT/linux-release-x86_64-clang-14 | 9 ++++ src/models/ModelTestfunctions.cpp | 3 +- 6 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 profiles/BSMPT/linux-debug-x86_64-clang-14 create mode 100644 profiles/BSMPT/linux-release-x86_64-clang-14 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a47b176..7d078877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ project( "BSMPT - Beyond the Standard Model Phase Transitions : A C++ package for the computation of the EWPT in BSM models" ) +set(CMAKE_CXX_FLAGS "-g") + + # -------------------------------- options -------------------------------- option(UseLibCMAES "Use libcmaes to minimize the potential" ON) diff --git a/Setup.py b/Setup.py index a76f46da..d9b0c63e 100644 --- a/Setup.py +++ b/Setup.py @@ -25,24 +25,31 @@ class BuildMode(ArgTypeEnum, Enum): release = (1,) debug = 2 +class Compiler(ArgTypeEnum, Enum): + gcc = 0, + clang = 1 -def get_compiler(): - compiler = "" + +def get_compiler(compiler: Compiler): + compilerString = "" if sys.platform != "linux" and sys.platform != "darwin": - return compiler + return compilerString if sys.platform == "linux": - compiler += "-gcc-" + if compiler == Compiler.gcc or compiler is None: + compilerString += "-gcc-" + else: + compilerString += "-clang-" if sys.platform == "darwin": - compiler += "-clang-" - compiler += get_compiler_version() + compilerString += "-clang-" + compilerString += get_compiler_version(compiler) - return compiler + return compilerString -def get_profile(os: str, arch: str, build_type: BuildMode): +def get_profile(os: str, arch: str, build_type: BuildMode, compiler: Compiler): profile = "" if os == "win32": profile += "windows" @@ -61,7 +68,7 @@ def get_profile(os: str, arch: str, build_type: BuildMode): profile += "-" profile += arch - profile += get_compiler() + profile += get_compiler(compiler) return profile @@ -106,14 +113,14 @@ def check_profile(profile): check_profile(profile) -def get_compiler_version(): - if sys.platform == "linux": +def get_compiler_version(compiler : Compiler): + if sys.platform == "linux" and compiler != Compiler.clang: version_response = subprocess.check_output( "gcc --version".split(), encoding="UTF-8" ).partition("\n")[0] semver_string = version_response[version_response.rfind(" ") + 1 :] return semver_string.partition(".")[0] - if sys.platform == "darwin": + elif sys.platform == "darwin" or compiler == Compiler.clang: version_response = subprocess.check_output( "clang --version".split(), encoding="UTF-8" ).partition("\n")[0] @@ -138,12 +145,12 @@ def setup_profiles(): shutil.copytree("profiles/BSMPT", profile_dir) -def conan_install(profile, additional_options=[], build_missing=False): +def conan_install(profile, additional_options=[], build_missing=False, compiler : Compiler = None): config_settings = [ "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" ] - build_profile = get_profile(sys.platform, get_arch(), BuildMode.release) + build_profile = get_profile(sys.platform, get_arch(), BuildMode.release, compiler) cmd = f"conan install . -pr:h BSMPT/{profile} -pr:b BSMPT/{build_profile} ".split() @@ -162,7 +169,7 @@ def conan_install(profile, additional_options=[], build_missing=False): def conan_install_all( - mode: BuildMode, options=[], build_missing=False, custom_profile="" + mode: BuildMode, options=[], build_missing=False, custom_profile="", compiler: Compiler = None ): if mode == BuildMode.all or mode == BuildMode.release: profile = ( @@ -175,6 +182,7 @@ def conan_install_all( profile, options, build_missing, + compiler ) if mode == BuildMode.all or mode == BuildMode.debug: profile = ( @@ -187,6 +195,7 @@ def conan_install_all( profile, options, build_missing, + compiler ) def create_cmaes(): @@ -260,6 +269,11 @@ def __str__(self): "-c", "--create", action="store_true", help="create the local conan package" ) + parser.add_argument("-co","--compiler", default=None, + type=Compiler.argtype, + choices=Compiler, + help="Force a certain compiler",) + opts = parser.parse_args() setup_profiles() @@ -276,4 +290,5 @@ def __str__(self): opts.options if opts.options is not None else [], opts.build_missing, opts.profile, + opts.compiler ) diff --git a/conanfile.py b/conanfile.py index d6f76658..b67cc362 100644 --- a/conanfile.py +++ b/conanfile.py @@ -51,7 +51,7 @@ class BSMPT(ConanFile): "EnableCoverage": False, "UseVectorization": True, "BuildExecutables": True, - "cmaes/*:shared": True + "cmaes/*:shared": True, } def requirements(self): @@ -140,7 +140,7 @@ def build(self): def package(self): cmake = CMake(self) cmake.install() - + def configure(self): if self.settings.os == "Windows": self.options["cmaes"].openmp = False diff --git a/profiles/BSMPT/linux-debug-x86_64-clang-14 b/profiles/BSMPT/linux-debug-x86_64-clang-14 new file mode 100644 index 00000000..8239ce4d --- /dev/null +++ b/profiles/BSMPT/linux-debug-x86_64-clang-14 @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +build_type=Debug +compiler=clang +compiler.cppstd=gnu17 +compiler.libcxx=libstdc++11 +compiler.version=14 +os=Linux + diff --git a/profiles/BSMPT/linux-release-x86_64-clang-14 b/profiles/BSMPT/linux-release-x86_64-clang-14 new file mode 100644 index 00000000..5220f8c4 --- /dev/null +++ b/profiles/BSMPT/linux-release-x86_64-clang-14 @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +build_type=Release +compiler=clang +compiler.cppstd=gnu17 +compiler.libcxx=libstdc++11 +compiler.version=14 +os=Linux + diff --git a/src/models/ModelTestfunctions.cpp b/src/models/ModelTestfunctions.cpp index ce975917..edca9bad 100644 --- a/src/models/ModelTestfunctions.cpp +++ b/src/models/ModelTestfunctions.cpp @@ -446,7 +446,8 @@ TestResults CheckTreeLevelMin(const Class_Potential_Origin &point, point.SMConstants, CheckVector, start, - WhichMinimizer); + WhichMinimizer, + false); std::string prsize_tline1 = "The given VEV configuration at tree-level is : "; std::string prsize_tline2 = "The calculated VEV configuration at tree-level is : "; From e723b1f81bc3c9d304589d729dfeae31e74ac7b9 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Thu, 18 Jul 2024 23:47:24 +0200 Subject: [PATCH 58/69] Disable vectorization --- CMakeLists.txt | 3 ++ Setup.py | 2 ++ conanfile.py | 2 +- tools/cmake/CompilerOptions.cmake | 1 + tools/conan/cmaes/patches/patch.diff | 51 ++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d078877..c876c67d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,9 @@ if(NOT Boost_FOUND) set(BSMPTCompileBaryo OFF) endif() +add_compile_options(-fsanitize=address) +add_link_options(-fsanitize=address) + set(CodeCoverageExcludesFromOtherPkgs "") if(NOT "${EIGEN3_ROOT_DIR}" STREQUAL "") list(APPEND CodeCoverageExcludesFromOtherPkgs "${EIGEN3_ROOT_DIR}/*") diff --git a/Setup.py b/Setup.py index d9b0c63e..ff729bf0 100644 --- a/Setup.py +++ b/Setup.py @@ -165,6 +165,8 @@ def conan_install(profile, additional_options=[], build_missing=False, compiler else: cmd += ["--build=cmaes/0.10.0"] + print(f"Executing command {cmd}") + subprocess.check_call(cmd) diff --git a/conanfile.py b/conanfile.py index b67cc362..41b18e70 100644 --- a/conanfile.py +++ b/conanfile.py @@ -49,7 +49,7 @@ class BSMPT(ConanFile): "MakeAdditionalTesting": False, "CompileBaryo": False, "EnableCoverage": False, - "UseVectorization": True, + "UseVectorization": False, "BuildExecutables": True, "cmaes/*:shared": True, } diff --git a/tools/cmake/CompilerOptions.cmake b/tools/cmake/CompilerOptions.cmake index 0b475a27..bb18fd9f 100644 --- a/tools/cmake/CompilerOptions.cmake +++ b/tools/cmake/CompilerOptions.cmake @@ -19,6 +19,7 @@ add_compile_options( ) if(BSMPTUseVectorization) +message(FATAL_ERROR "DONT") include(CheckCXXCompilerFlag) check_cxx_compiler_flag("-march=native" _march_native_works) diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff index ba728f3d..496df34a 100644 --- a/tools/conan/cmaes/patches/patch.diff +++ b/tools/conan/cmaes/patches/patch.diff @@ -114,6 +114,27 @@ index 0000000..af4f716 + + set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") + endif() +diff --git a/include/libcmaes/cmastrategy.h b/include/libcmaes/cmastrategy.h +index c8dc1f6..01fc948 100644 +--- a/include/libcmaes/cmastrategy.h ++++ b/include/libcmaes/cmastrategy.h +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + + namespace libcmaes + { +@@ -123,7 +124,7 @@ namespace libcmaes + protected: + Eigen::EigenMultivariateNormal _esolver; /**< multivariate normal distribution sampler, and eigendecomposition solver. */ + CMAStopCriteria _stopcriteria; /**< holds the set of termination criteria, see reference paper. */ +- std::ofstream *_fplotstream = nullptr; /**< plotting file stream, not in parameters because of copy-constructor hell. */ ++ std::shared_ptr _fplotstream = nullptr; /**< plotting file stream, not in parameters because of copy-constructor hell. */ + + public: + static ProgressFunc,CMASolutions> _defaultPFunc; /**< the default progress function. */ diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h index fb8b11d..6a6943b 100644 --- a/include/libcmaes/eigenmvn.h @@ -140,3 +161,33 @@ index fb8b11d..6a6943b 100644 scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) { +diff --git a/src/cmastrategy.cc b/src/cmastrategy.cc +index cc8814c..e628085 100644 +--- a/src/cmastrategy.cc ++++ b/src/cmastrategy.cc +@@ -109,7 +109,7 @@ namespace libcmaes + LOG_IF(INFO,!eostrat::_parameters._quiet) << "CMA-ES / dim=" << eostrat::_parameters._dim << " / lambda=" << eostrat::_parameters._lambda << " / sigma0=" << eostrat::_solutions._sigma << " / mu=" << eostrat::_parameters._mu << " / mueff=" << eostrat::_parameters._muw << " / c1=" << eostrat::_parameters._c1 << " / cmu=" << eostrat::_parameters._cmu << " / tpa=" << (eostrat::_parameters._tpa==2) << " / threads=" << Eigen::nbThreads() << std::endl; + if (!eostrat::_parameters._fplot.empty()) + { +- _fplotstream = new std::ofstream(eostrat::_parameters._fplot); ++ _fplotstream = std::make_shared(eostrat::_parameters._fplot); + _fplotstream->precision(std::numeric_limits::digits10); + } + auto mit=eostrat::_parameters._stoppingcrit.begin(); +@@ -133,14 +133,14 @@ namespace libcmaes + _esolver = Eigen::EigenMultivariateNormal(false,eostrat::_parameters._seed); // seeding the multivariate normal generator. + LOG_IF(INFO,!eostrat::_parameters._quiet) << "CMA-ES / dim=" << eostrat::_parameters._dim << " / lambda=" << eostrat::_parameters._lambda << " / sigma0=" << eostrat::_solutions._sigma << " / mu=" << eostrat::_parameters._mu << " / mueff=" << eostrat::_parameters._muw << " / c1=" << eostrat::_parameters._c1 << " / cmu=" << eostrat::_parameters._cmu << " / lazy_update=" << eostrat::_parameters._lazy_update << std::endl; + if (!eostrat::_parameters._fplot.empty()) +- _fplotstream = new std::ofstream(eostrat::_parameters._fplot); ++ _fplotstream = std::make_shared(std::ofstream(eostrat::_parameters._fplot)); + } + + template + CMAStrategy::~CMAStrategy() + { + if (!eostrat::_parameters._fplot.empty()) +- delete _fplotstream; ++ _fplotstream.reset(); + } + + template From 542584afe7a7f56fd954c0bdda5f7e35e7c1d485 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:13:55 +0200 Subject: [PATCH 59/69] fix missing arguments --- Setup.py | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/Setup.py b/Setup.py index ff729bf0..56efbb10 100644 --- a/Setup.py +++ b/Setup.py @@ -25,8 +25,9 @@ class BuildMode(ArgTypeEnum, Enum): release = (1,) debug = 2 + class Compiler(ArgTypeEnum, Enum): - gcc = 0, + gcc = (0,) clang = 1 @@ -113,7 +114,7 @@ def check_profile(profile): check_profile(profile) -def get_compiler_version(compiler : Compiler): +def get_compiler_version(compiler: Compiler): if sys.platform == "linux" and compiler != Compiler.clang: version_response = subprocess.check_output( "gcc --version".split(), encoding="UTF-8" @@ -145,7 +146,9 @@ def setup_profiles(): shutil.copytree("profiles/BSMPT", profile_dir) -def conan_install(profile, additional_options=[], build_missing=False, compiler : Compiler = None): +def conan_install( + profile, additional_options=[], build_missing=False, compiler: Compiler = None +): config_settings = [ "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" ] @@ -171,46 +174,42 @@ def conan_install(profile, additional_options=[], build_missing=False, compiler def conan_install_all( - mode: BuildMode, options=[], build_missing=False, custom_profile="", compiler: Compiler = None + mode: BuildMode, + options=[], + build_missing=False, + custom_profile="", + compiler: Compiler = None, ): if mode == BuildMode.all or mode == BuildMode.release: profile = ( custom_profile if custom_profile != "" - else get_profile(sys.platform, get_arch(), BuildMode.release) + else get_profile(sys.platform, get_arch(), BuildMode.release, compiler) ) check_profile(profile) - conan_install( - profile, - options, - build_missing, - compiler - ) + conan_install(profile, options, build_missing, compiler) if mode == BuildMode.all or mode == BuildMode.debug: profile = ( custom_profile if custom_profile != "" - else get_profile(sys.platform, get_arch(), BuildMode.debug) + else get_profile(sys.platform, get_arch(), BuildMode.debug, compiler) ) check_profile(profile) - conan_install( - profile, - options, - build_missing, - compiler - ) + conan_install(profile, options, build_missing, compiler) + def create_cmaes(): cmd = "conan export . --version=0.10.0".split() subprocess.check_call(cmd, cwd="tools/conan/cmaes") -def create(build_missing=False): + +def create(build_missing=False, compiler: Compiler = None): config_settings = [ "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" ] - profile = get_profile(sys.platform, get_arch(), BuildMode.release) + profile = get_profile(sys.platform, get_arch(), BuildMode.release, compiler) cmd = f"conan create . -pr:h BSMPT/{profile} -pr:b BSMPT/{profile}".split() for conf in config_settings: @@ -222,7 +221,6 @@ def create(build_missing=False): cmd += ["--options", "EnableTests=False"] cmd += ["--options", "BuildExecutables=False"] - subprocess.check_call(cmd) @@ -271,10 +269,14 @@ def __str__(self): "-c", "--create", action="store_true", help="create the local conan package" ) - parser.add_argument("-co","--compiler", default=None, + parser.add_argument( + "-co", + "--compiler", + default=None, type=Compiler.argtype, choices=Compiler, - help="Force a certain compiler",) + help="Force a certain compiler", + ) opts = parser.parse_args() @@ -283,14 +285,13 @@ def __str__(self): create_cmaes() if opts.create: - create(build_missing=opts.build_missing,) + create(build_missing=opts.build_missing, compiler=opts.compiler) else: - conan_install_all( opts.mode, opts.options if opts.options is not None else [], opts.build_missing, opts.profile, - opts.compiler + opts.compiler, ) From 5a96b7745e733e04123606a470f532daca48506e Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:23:38 +0200 Subject: [PATCH 60/69] disable sanitize --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c876c67d..546accf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,8 @@ if(NOT Boost_FOUND) set(BSMPTCompileBaryo OFF) endif() -add_compile_options(-fsanitize=address) -add_link_options(-fsanitize=address) +# add_compile_options(-fsanitize=address) +# add_link_options(-fsanitize=address) set(CodeCoverageExcludesFromOtherPkgs "") if(NOT "${EIGEN3_ROOT_DIR}" STREQUAL "") From 7d83690e1bcc01528c85bc1afcd53c2d83b6a7a9 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:50:49 +0200 Subject: [PATCH 61/69] disable fail fast --- .github/workflows/conan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 61a50dd7..1ccf048d 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -19,6 +19,7 @@ concurrency: jobs: conan: strategy: + fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest] runs-on: ${{matrix.os}} From 7765496489204307f5c2d0bedaed168f1d4f21e6 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 22 Jul 2024 07:36:59 +0200 Subject: [PATCH 62/69] Try different settings --- CMakeLists.txt | 2 +- Setup.py | 13 +++++-- conanfile.py | 15 ++++++-- src/Kfactors/CMakeLists.txt | 6 ++-- src/baryo_calculation/CMakeLists.txt | 1 - src/minimizer/LibCMAES/CMakeLists.txt | 6 ++-- test_package/CMakeLists.txt | 13 +++++++ test_package/src/example.cpp | 2 +- tests/CMakeLists.txt | 2 +- tests/unittests/CMakeLists.txt | 2 +- tools/cmake/CMAES.cmake | 2 +- tools/conan/cmaes/patches/patch.diff | 51 --------------------------- 12 files changed, 46 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 546accf7..fea351f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,7 +162,7 @@ if(EnableCoverage) GenericTests) endif(EnableCoverage) -find_lto(CXX) +# find_lto(CXX) add_subdirectory(src) add_subdirectory(standalone) diff --git a/Setup.py b/Setup.py index 56efbb10..9536844a 100644 --- a/Setup.py +++ b/Setup.py @@ -203,7 +203,7 @@ def create_cmaes(): subprocess.check_call(cmd, cwd="tools/conan/cmaes") -def create(build_missing=False, compiler: Compiler = None): +def create(build_missing=False, compiler: Compiler = None, additional_options=[]): config_settings = [ "tools.cmake.cmake_layout:build_folder_vars=['settings.os','settings.arch','settings.build_type']" @@ -218,7 +218,10 @@ def create(build_missing=False, compiler: Compiler = None): if build_missing: cmd += ["--build=missing"] - cmd += ["--options", "EnableTests=False"] + for option in additional_options: + cmd += ["--options", option] + + # cmd += ["--options", "EnableTests=False"] cmd += ["--options", "BuildExecutables=False"] subprocess.check_call(cmd) @@ -285,7 +288,11 @@ def __str__(self): create_cmaes() if opts.create: - create(build_missing=opts.build_missing, compiler=opts.compiler) + create( + build_missing=opts.build_missing, + compiler=opts.compiler, + additional_options=opts.options if opts.options is not None else [], + ) else: conan_install_all( diff --git a/conanfile.py b/conanfile.py index 41b18e70..d4b13504 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,6 +5,7 @@ from conan.tools.files import load from conan.tools.scm import Git import os, re +from conan.tools.env import Environment required_conan_version = ">=2.0.0 <3" @@ -137,6 +138,15 @@ def build(self): cmake.configure() cmake.build() + environment = Environment() + environment.define("CTEST_OUTPUT_ON_FAILURE","1") + envvars = environment.vars(self) + + + if self.options.get_safe("EnableTests"): + with envvars.apply(): + cmake.test() + def package(self): cmake = CMake(self) cmake.install() @@ -149,7 +159,6 @@ def package_id(self): del self.info.options.EnableTests def package_info(self): - if self.settings.compiler == "msvc": openmp_flags = ["-openmp"] elif self.settings.compiler in ("gcc", "clang"): @@ -265,8 +274,8 @@ def package_info(self): self.cpp_info.components["Models"].set_property( "cmake_target_name", "BSMPT::Models" ) - self.cpp_info.components["Models"].exelinkflags = openmp_flags - self.cpp_info.components["Models"].sharedlinkflags = openmp_flags + # self.cpp_info.components["Models"].exelinkflags = openmp_flags + # self.cpp_info.components["Models"].sharedlinkflags = openmp_flags self.cpp_info.components["ThermalFunctions"].libs = ["ThermalFunctions"] self.cpp_info.components["ThermalFunctions"].requires = ["gsl::gsl", "Utility"] diff --git a/src/Kfactors/CMakeLists.txt b/src/Kfactors/CMakeLists.txt index 6d62483a..f6abc36d 100644 --- a/src/Kfactors/CMakeLists.txt +++ b/src/Kfactors/CMakeLists.txt @@ -16,8 +16,8 @@ add_library(Kfactors ${header} ${src}) target_link_libraries(Kfactors PUBLIC Eigen3::Eigen GSL::gsl Boost::boost Minimizer Utility) -if(OpenMP_FOUND) - target_link_libraries(Kfactors PUBLIC OpenMP::OpenMP_CXX) -endif() +# if(OpenMP_FOUND) +# target_link_libraries(Kfactors PUBLIC OpenMP::OpenMP_CXX) +# endif() target_include_directories(Kfactors PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(Kfactors PUBLIC cxx_std_17) diff --git a/src/baryo_calculation/CMakeLists.txt b/src/baryo_calculation/CMakeLists.txt index 083a6bb6..93535d6a 100644 --- a/src/baryo_calculation/CMakeLists.txt +++ b/src/baryo_calculation/CMakeLists.txt @@ -32,6 +32,5 @@ target_link_libraries( LibWallThickness Utility Boost::boost) -# target_compile_options(Baryo PUBLIC ${OpenMP_CXX_FLAGS}) target_include_directories(Baryo PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(Baryo PUBLIC cxx_std_17) diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt index 32cb1ac9..12680873 100644 --- a/src/minimizer/LibCMAES/CMakeLists.txt +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -13,9 +13,9 @@ target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) -if(OpenMP_FOUND) - target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) -endif() +# if(OpenMP_FOUND) +# target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) +# endif() target_include_directories( Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 77e9b8bd..95d11b67 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -12,3 +12,16 @@ add_compile_options( add_executable(example src/example.cpp) target_link_libraries(example BSMPT::Utility BSMPT::BounceSolution BSMPT::Models BSMPT::Minimizer) + +include(../tools/cmake/CompilerOptions.cmake) + +add_compile_options( + $<$:-DCOMPILEDEBUG=true> + $<$,$,$>:-pedantic> + $<$,$,$>:-Wall> + $<$,$,$>:-Wextra> + $<$,$,$>:-Wshadow> + $<$,$,$,$>>:-Wmissing-declarations> + $<$,$,$,$>>:-Wmissing-include-dirs> + $<$,$,$,$>>:-O3> +) \ No newline at end of file diff --git a/test_package/src/example.cpp b/test_package/src/example.cpp index fd4d656b..6c1a093b 100644 --- a/test_package/src/example.cpp +++ b/test_package/src/example.cpp @@ -31,6 +31,6 @@ int main() std::vector check; std::vector start(0, 8); - auto result = Minimizer::Minimize_gen_all(testModel, 0, check, start); + auto result = Minimizer::Minimize_gen_all(testModel, 0, check, start, BSMPT::Minimizer::WhichMinimizerDefault, false); std::cout << "result = " << result << std::endl; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f0000eaa..3abe01ac 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,4 +21,4 @@ endif() add_subdirectory(catcheventlistener) add_subdirectory(GenerateTestCompares) add_subdirectory(unittests) -add_subdirectory(benchmarks) +# add_subdirectory(benchmarks) diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index 0b380fa1..12040f3f 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -5,7 +5,7 @@ set(TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}) -file(GLOB SOURCE_FILES "Test-*.cpp" CONFIURE_DEPENDS) +file(GLOB SOURCE_FILES "Test-c2hdm.cpp" CONFIURE_DEPENDS) add_executable(GenericTests ${SOURCE_FILES}) target_link_libraries( GenericTests diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 3ace4bc8..ab967bcc 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -1,2 +1,2 @@ -find_package(OpenMP CONFIG QUIET) +# find_package(OpenMP CONFIG QUIET) find_package(cmaes 0.10 REQUIRED) diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff index 496df34a..ba728f3d 100644 --- a/tools/conan/cmaes/patches/patch.diff +++ b/tools/conan/cmaes/patches/patch.diff @@ -114,27 +114,6 @@ index 0000000..af4f716 + + set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") + endif() -diff --git a/include/libcmaes/cmastrategy.h b/include/libcmaes/cmastrategy.h -index c8dc1f6..01fc948 100644 ---- a/include/libcmaes/cmastrategy.h -+++ b/include/libcmaes/cmastrategy.h -@@ -31,6 +31,7 @@ - #include - #include - #include -+#include - - namespace libcmaes - { -@@ -123,7 +124,7 @@ namespace libcmaes - protected: - Eigen::EigenMultivariateNormal _esolver; /**< multivariate normal distribution sampler, and eigendecomposition solver. */ - CMAStopCriteria _stopcriteria; /**< holds the set of termination criteria, see reference paper. */ -- std::ofstream *_fplotstream = nullptr; /**< plotting file stream, not in parameters because of copy-constructor hell. */ -+ std::shared_ptr _fplotstream = nullptr; /**< plotting file stream, not in parameters because of copy-constructor hell. */ - - public: - static ProgressFunc,CMASolutions> _defaultPFunc; /**< the default progress function. */ diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h index fb8b11d..6a6943b 100644 --- a/include/libcmaes/eigenmvn.h @@ -161,33 +140,3 @@ index fb8b11d..6a6943b 100644 scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) { -diff --git a/src/cmastrategy.cc b/src/cmastrategy.cc -index cc8814c..e628085 100644 ---- a/src/cmastrategy.cc -+++ b/src/cmastrategy.cc -@@ -109,7 +109,7 @@ namespace libcmaes - LOG_IF(INFO,!eostrat::_parameters._quiet) << "CMA-ES / dim=" << eostrat::_parameters._dim << " / lambda=" << eostrat::_parameters._lambda << " / sigma0=" << eostrat::_solutions._sigma << " / mu=" << eostrat::_parameters._mu << " / mueff=" << eostrat::_parameters._muw << " / c1=" << eostrat::_parameters._c1 << " / cmu=" << eostrat::_parameters._cmu << " / tpa=" << (eostrat::_parameters._tpa==2) << " / threads=" << Eigen::nbThreads() << std::endl; - if (!eostrat::_parameters._fplot.empty()) - { -- _fplotstream = new std::ofstream(eostrat::_parameters._fplot); -+ _fplotstream = std::make_shared(eostrat::_parameters._fplot); - _fplotstream->precision(std::numeric_limits::digits10); - } - auto mit=eostrat::_parameters._stoppingcrit.begin(); -@@ -133,14 +133,14 @@ namespace libcmaes - _esolver = Eigen::EigenMultivariateNormal(false,eostrat::_parameters._seed); // seeding the multivariate normal generator. - LOG_IF(INFO,!eostrat::_parameters._quiet) << "CMA-ES / dim=" << eostrat::_parameters._dim << " / lambda=" << eostrat::_parameters._lambda << " / sigma0=" << eostrat::_solutions._sigma << " / mu=" << eostrat::_parameters._mu << " / mueff=" << eostrat::_parameters._muw << " / c1=" << eostrat::_parameters._c1 << " / cmu=" << eostrat::_parameters._cmu << " / lazy_update=" << eostrat::_parameters._lazy_update << std::endl; - if (!eostrat::_parameters._fplot.empty()) -- _fplotstream = new std::ofstream(eostrat::_parameters._fplot); -+ _fplotstream = std::make_shared(std::ofstream(eostrat::_parameters._fplot)); - } - - template - CMAStrategy::~CMAStrategy() - { - if (!eostrat::_parameters._fplot.empty()) -- delete _fplotstream; -+ _fplotstream.reset(); - } - - template From 5bd9e958d3790fa1d7a9fe0afe3f9e11c52f0338 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:39:45 +0200 Subject: [PATCH 63/69] disable fixed abi --- .gitignore | 2 ++ tools/cmake/CompilerOptions.cmake | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 828cdda3..24f1272a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ __pycache__/* test_package/build/ CMakeLists.txt.user +CMakeCache.txt +CMakeFiles/cmake.check_cache diff --git a/tools/cmake/CompilerOptions.cmake b/tools/cmake/CompilerOptions.cmake index bb18fd9f..112125f0 100644 --- a/tools/cmake/CompilerOptions.cmake +++ b/tools/cmake/CompilerOptions.cmake @@ -3,9 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -add_compile_definitions( - $<$,$,$>:_GLIBCXX_USE_CXX11_ABI=1> -) +# add_compile_definitions( +# $<$,$,$>:_GLIBCXX_USE_CXX11_ABI=1> +# ) add_compile_options( $<$:-DCOMPILEDEBUG=true> From d6a19a3eb17bbe77d4f1acbbcaa5b617a9715442 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:52:44 +0200 Subject: [PATCH 64/69] Update conanfile --- tools/conan/cmaes/conanfile.py | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/tools/conan/cmaes/conanfile.py b/tools/conan/cmaes/conanfile.py index f304adc0..af61caef 100644 --- a/tools/conan/cmaes/conanfile.py +++ b/tools/conan/cmaes/conanfile.py @@ -1,6 +1,7 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches +from conan.tools.build import check_min_cppstd import os class CmaesConan(ConanFile): @@ -8,14 +9,13 @@ class CmaesConan(ConanFile): generators = "CMakeDeps" - # Optional metadata - license = "LGPLv3" + license = "LGPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/CMA-ES/libcmaes" description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" topics = ("cmaes", "minimization") + package_type = "library" - # Binary configuration settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], @@ -32,6 +32,26 @@ class CmaesConan(ConanFile): short_paths = True + @property + def _min_cppstd(self): + return 11 + + @property + def _openmp_flags(self): + if self.settings.compiler == "clang": + return ["-fopenmp=libomp"] + elif self.settings.compiler == "apple-clang": + return ["-Xclang", "-fopenmp"] + elif self.settings.compiler == "gcc": + return ["-fopenmp"] + elif self.settings.compiler == "intel-cc": + return ["-Qopenmp"] + elif self.settings.compiler == "sun-cc": + return ["-xopenmp"] + elif is_msvc(self): + return ["-openmp"] + return None + def export_sources(self): export_conandata_patches(self) @@ -43,8 +63,8 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp: - self.requires("llvm-openmp/17.0.6", transitive_headers=True) + if self.options.openmp and self.settings.compiler in ["clang", "apple-clang"]: + self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) def config_options(self): if self.settings.os == "Windows": @@ -85,3 +105,15 @@ def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") + if self.options.openmp: + if self.settings.compiler in ["clang", "apple-clang"]: + self.cpp_info.requires.append("llvm-openmp::llvm-openmp") + openmp_flags = self._openmp_flags + self.cpp_info.cflags = openmp_flags + self.cpp_info.cxxflags = openmp_flags + self.cpp_info.sharedlinkflags = openmp_flags + self.cpp_info.exelinkflags = openmp_flags + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) \ No newline at end of file From 8230d5406495a5ce9f52d885e1e6c0bb4d10f9f3 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 22 Jul 2024 23:00:55 +0200 Subject: [PATCH 65/69] add eigen to required packages --- tools/conan/cmaes/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/conan/cmaes/conanfile.py b/tools/conan/cmaes/conanfile.py index af61caef..3bfd05bc 100644 --- a/tools/conan/cmaes/conanfile.py +++ b/tools/conan/cmaes/conanfile.py @@ -105,6 +105,8 @@ def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") + self.cpp_info.requires.append("eigen::eigen") + if self.options.openmp: if self.settings.compiler in ["clang", "apple-clang"]: self.cpp_info.requires.append("llvm-openmp::llvm-openmp") From a34859588a1a96b1b31d8808d6174d39de2d7fa0 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 11 Aug 2024 08:19:26 +0200 Subject: [PATCH 66/69] return cmaes to cmake --- run_clang.sh | 3 +++ test_package/.vscode/launch.json | 33 ++++++++++++++++++++++++++++++ tools/cmake/CMAES.cmake | 35 ++++++++++++++++++++++++++++++-- 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 run_clang.sh create mode 100644 test_package/.vscode/launch.json diff --git a/run_clang.sh b/run_clang.sh new file mode 100644 index 00000000..232c58ed --- /dev/null +++ b/run_clang.sh @@ -0,0 +1,3 @@ +CC=clang +CXX=clang++ +python3 Setup.py -p linux-release-x86_64-clang-14 --compiler clang -m release -b --create diff --git a/test_package/.vscode/launch.json b/test_package/.vscode/launch.json new file mode 100644 index 00000000..b2fa92e2 --- /dev/null +++ b/test_package/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/linux-x86_64-release/example", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + + ] +} \ No newline at end of file diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index ab967bcc..99b34f8c 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -1,2 +1,33 @@ -# find_package(OpenMP CONFIG QUIET) -find_package(cmaes 0.10 REQUIRED) +find_package(OpenMP QUIET) +find_package(libcmaes 0.10 QUIET) +if(NOT libcmaes_FOUND) + set(BSMPT_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(BSMPT_CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + set(BSMPT_CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + set(EXPORT_CMAES TRUE) + FetchContent_Declare( + libcmaes + GIT_REPOSITORY https://github.com/CMA-ES/libcmaes.git + GIT_TAG v0.10) + FetchContent_GetProperties(libcmaes) + if(NOT libcmaes_POPULATED) + option(LIBCMAES_BUILD_TESTS OFF) + option(LIBCMAES_BUILD_PYTHON OFF) + option(LIBCMAES_BUILD_EXAMPLES OFF) + option(LIBCMAES_USE_OPENMP OpenMP_FOUND) + FetchContent_Populate(libcmaes) + add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) + include(GenerateExportHeader) + generate_export_header( + cmaes EXPORT_FILE_NAME + ${libcmaes_SOURCE_DIR}/include/libcmaes/cmaes_export.h) + message(STATUS ${libcmaes_SOURCE_DIR}) + set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs} + "${libcmaes_SOURCE_DIR}/*") + endif() + + set(libcmaes_FOUND TRUE) +else() + set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs} + "${libcmaes_ROOT_DIR}/*") +endif() From 1042269fb5bd6d759f9db34a2783ac862b9af0df Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 11 Aug 2024 08:19:28 +0200 Subject: [PATCH 67/69] return cmaes to cmake --- CMakeLists.txt | 47 --------- Setup.py | 7 -- conanfile.py | 25 +---- src/Kfactors/CMakeLists.txt | 3 - src/minimizer/LibCMAES/CMakeLists.txt | 5 +- tools/cmake/BSMPTConfig.cmake.in | 30 ------ tools/cmake/CMAES.cmake | 2 + tools/conan/cmaes/conandata.yml | 7 -- tools/conan/cmaes/conanfile.py | 121 ---------------------- tools/conan/cmaes/patches/patch.diff | 142 -------------------------- 10 files changed, 5 insertions(+), 384 deletions(-) delete mode 100644 tools/cmake/BSMPTConfig.cmake.in delete mode 100644 tools/conan/cmaes/conandata.yml delete mode 100644 tools/conan/cmaes/conanfile.py delete mode 100644 tools/conan/cmaes/patches/patch.diff diff --git a/CMakeLists.txt b/CMakeLists.txt index fea351f4..1294ebbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,53 +167,6 @@ endif(EnableCoverage) add_subdirectory(src) add_subdirectory(standalone) -# ----- installation - -# -------------------------- export as cmake package -------------------------- -if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - include(CMakePackageConfigHelpers) - write_basic_package_version_file( - BSMPTConfigVersion.cmake - VERSION ${PACKAGE_VERSION} - COMPATIBILITY AnyNewerVersion) - - set(ExportList - Models - Minimizer - ThermalFunctions - Utility - Spline - ASCIIPlotter - BSMPT_Config) - if(cmaes_FOUND) - list(APPEND ExportList Minimizer_CMAES) - endif() - if(NLopt_FOUND) - list(APPEND ExportList Minimizer_NLOPT) - endif() - - if(BSMPTCompileBaryo) - set(ExportList ${ExportList} Baryo LibWallThickness Kfactors) - endif(BSMPTCompileBaryo) - - export( - TARGETS ${ExportList} - NAMESPACE BSMPT:: - FILE BSMPTTargets.cmake) - - if(EXPORT_CMAES) - export( - TARGETS cmaes - NAMESPACE libcmaes:: - APPEND - FILE BSMPTTargets.cmake) - endif(EXPORT_CMAES) - - configure_file(tools/cmake/BSMPTConfig.cmake.in BSMPTConfig.cmake @ONLY) - - export(PACKAGE BSMPT) -endif() - # ------------------------ Doxygen -------------------------------------------- if(BSMPT_IS_TOPLEVEL) find_package(Doxygen) diff --git a/Setup.py b/Setup.py index 9536844a..abd5639b 100644 --- a/Setup.py +++ b/Setup.py @@ -198,11 +198,6 @@ def conan_install_all( conan_install(profile, options, build_missing, compiler) -def create_cmaes(): - cmd = "conan export . --version=0.10.0".split() - subprocess.check_call(cmd, cwd="tools/conan/cmaes") - - def create(build_missing=False, compiler: Compiler = None, additional_options=[]): config_settings = [ @@ -285,8 +280,6 @@ def __str__(self): setup_profiles() - create_cmaes() - if opts.create: create( build_missing=opts.build_missing, diff --git a/conanfile.py b/conanfile.py index d4b13504..e1f0240b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -52,7 +52,6 @@ class BSMPT(ConanFile): "EnableCoverage": False, "UseVectorization": False, "BuildExecutables": True, - "cmaes/*:shared": True, } def requirements(self): @@ -66,9 +65,6 @@ def requirements(self): if self.options.UseNLopt: self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) - if self.options.UseLibCMAES: - self.requires("cmaes/0.10.0", transitive_headers=True, transitive_libs=True) - def build_requirements(self): self.tool_requires("cmake/3.29.0") @@ -139,10 +135,9 @@ def build(self): cmake.build() environment = Environment() - environment.define("CTEST_OUTPUT_ON_FAILURE","1") + environment.define("CTEST_OUTPUT_ON_FAILURE", "1") envvars = environment.vars(self) - if self.options.get_safe("EnableTests"): with envvars.apply(): cmake.test() @@ -151,23 +146,10 @@ def package(self): cmake = CMake(self) cmake.install() - def configure(self): - if self.settings.os == "Windows": - self.options["cmaes"].openmp = False - def package_id(self): del self.info.options.EnableTests def package_info(self): - if self.settings.compiler == "msvc": - openmp_flags = ["-openmp"] - elif self.settings.compiler in ("gcc", "clang"): - openmp_flags = ["-fopenmp"] - elif self.settings.compiler == "apple-clang": - openmp_flags = ["-Xpreprocessor", "-fopenmp"] - else: - openmp_flags = [] - self.cpp_info.components["ASCIIPlotter"].libs = ["ASCIIPlotter"] self.cpp_info.components["ASCIIPlotter"].requires = [ "nlohmann_json::nlohmann_json", @@ -245,9 +227,6 @@ def package_info(self): "cmake_target_name", "BSMPT::Minimizer" ) - if self.options.UseLibCMAES: - self.cpp_info.components["Minimizer"].requires.append("cmaes::cmaes") - if self.options.UseNLopt: self.cpp_info.components["Minimizer"].requires.append("nlopt::nlopt") @@ -274,8 +253,6 @@ def package_info(self): self.cpp_info.components["Models"].set_property( "cmake_target_name", "BSMPT::Models" ) - # self.cpp_info.components["Models"].exelinkflags = openmp_flags - # self.cpp_info.components["Models"].sharedlinkflags = openmp_flags self.cpp_info.components["ThermalFunctions"].libs = ["ThermalFunctions"] self.cpp_info.components["ThermalFunctions"].requires = ["gsl::gsl", "Utility"] diff --git a/src/Kfactors/CMakeLists.txt b/src/Kfactors/CMakeLists.txt index f6abc36d..7ce4ab41 100644 --- a/src/Kfactors/CMakeLists.txt +++ b/src/Kfactors/CMakeLists.txt @@ -16,8 +16,5 @@ add_library(Kfactors ${header} ${src}) target_link_libraries(Kfactors PUBLIC Eigen3::Eigen GSL::gsl Boost::boost Minimizer Utility) -# if(OpenMP_FOUND) -# target_link_libraries(Kfactors PUBLIC OpenMP::OpenMP_CXX) -# endif() target_include_directories(Kfactors PUBLIC ${BSMPT_SOURCE_DIR}/include) target_compile_features(Kfactors PUBLIC cxx_std_17) diff --git a/src/minimizer/LibCMAES/CMakeLists.txt b/src/minimizer/LibCMAES/CMakeLists.txt index 12680873..57b509bf 100644 --- a/src/minimizer/LibCMAES/CMakeLists.txt +++ b/src/minimizer/LibCMAES/CMakeLists.txt @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +include(CMAES) + set(suffix "include/BSMPT/minimizer/LibCMAES") set(header_path "${BSMPT_SOURCE_DIR}/${suffix}") set(header ${header_path}/MinimizeLibCMAES.h) @@ -13,9 +15,6 @@ target_link_libraries(Minimizer_CMAES INTERFACE Minimizer) target_link_libraries(Minimizer_CMAES INTERFACE libcmaes::cmaes) -# if(OpenMP_FOUND) -# target_link_libraries(Minimizer_CMAES INTERFACE OpenMP::OpenMP_CXX) -# endif() target_include_directories( Minimizer_CMAES INTERFACE ${BSMPT_SOURCE_DIR}/include diff --git a/tools/cmake/BSMPTConfig.cmake.in b/tools/cmake/BSMPTConfig.cmake.in deleted file mode 100644 index 6d7a623b..00000000 --- a/tools/cmake/BSMPTConfig.cmake.in +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas Müller -# -# SPDX-License-Identifier: GPL-3.0-or-later -include(CMakeFindDependencyMacro) - -list(APPEND CMAKE_MODULE_PATH "@BSMPT_SOURCE_DIR@/tools/cmake") -@CMAES_DEPENDENCY@ - -find_dependency(Eigen3 @EIGEN3_VERSION@) -find_dependency(Boost @Boost_VERSION_STRING@) - - -find_dependency(GSL @GSL_VERSION@) -find_dependency(OpenMP @OpenMP_CXX_VERSION@) -find_dependency(Threads @Threads_VERSION@) - -if(@cmaes_FOUND@ AND NOT @EXPORT_CMAES@) - #find_dependency(cmaes) -endif(@cmaes_FOUND@ AND NOT @EXPORT_CMAES@) - -if(@NLopt_FOUND@) - find_dependency(NLopt @NLopt_VERSION@) -endif(@NLopt_FOUND@) - -if(@nlohmann_json_FOUND@) - find_dependency(nlohmann_json @nlohmann_json_VERSION@) -endif() - -# Add the targets file -include("${CMAKE_CURRENT_LIST_DIR}/BSMPTTargets.cmake") diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 99b34f8c..80ac5f66 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -31,3 +31,5 @@ else() set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs} "${libcmaes_ROOT_DIR}/*") endif() + +set(cmaes_FOUND ${libcmaes_FOUND}) \ No newline at end of file diff --git a/tools/conan/cmaes/conandata.yml b/tools/conan/cmaes/conandata.yml deleted file mode 100644 index 1afc856c..00000000 --- a/tools/conan/cmaes/conandata.yml +++ /dev/null @@ -1,7 +0,0 @@ -sources: - "0.10.0": - url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" - sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" -patches: - "0.10.0": - - patch_file: "patches/patch.diff" diff --git a/tools/conan/cmaes/conanfile.py b/tools/conan/cmaes/conanfile.py deleted file mode 100644 index 3bfd05bc..00000000 --- a/tools/conan/cmaes/conanfile.py +++ /dev/null @@ -1,121 +0,0 @@ -from conan import ConanFile -from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches -from conan.tools.build import check_min_cppstd -import os - -class CmaesConan(ConanFile): - name = "cmaes" - - generators = "CMakeDeps" - - license = "LGPL-3.0-or-later" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/CMA-ES/libcmaes" - description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" - topics = ("cmaes", "minimization") - package_type = "library" - - settings = "os", "compiler", "build_type", "arch" - options = { - "shared": [True, False], - "fPIC": [True, False], - "openmp": [True, False], - "surrog": [True, False], - } - default_options = { - "shared": False, - "fPIC": True, - "openmp": True, - "surrog": True, - } - - short_paths = True - - @property - def _min_cppstd(self): - return 11 - - @property - def _openmp_flags(self): - if self.settings.compiler == "clang": - return ["-fopenmp=libomp"] - elif self.settings.compiler == "apple-clang": - return ["-Xclang", "-fopenmp"] - elif self.settings.compiler == "gcc": - return ["-fopenmp"] - elif self.settings.compiler == "intel-cc": - return ["-Qopenmp"] - elif self.settings.compiler == "sun-cc": - return ["-xopenmp"] - elif is_msvc(self): - return ["-openmp"] - return None - - def export_sources(self): - export_conandata_patches(self) - - def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True) - - def build_requirements(self): - pass - - def requirements(self): - self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp and self.settings.compiler in ["clang", "apple-clang"]: - self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - if self.options.shared: - self.options.rm_safe("fPIC") - - def layout(self): - cmake_layout(self,src_folder="src") - - def generate(self): - tc = CMakeToolchain(self) - tc.variables["LIBCMAES_BUILD_EXAMPLES"] = False - tc.variables["LIBCMAES_BUILD_SHARED_LIBS"] = self.options.shared - tc.variables["LIBCMAES_USE_OPENMP"] = self.options.openmp - tc.variables["LIBCMAES_ENABLE_SURROG"] = self.options.surrog - tc.variables["LIBCMAES_BUILD_PYTHON"] = False - tc.variables["LIBCMAES_BUILD_TESTS"] = False - tc.generate() - - def build(self): - apply_conandata_patches(self) - cmake = CMake(self) - cmake.configure() - cmake.build() - - def package(self): - cmake = CMake(self) - cmake.install() - - rmdir(self, os.path.join(self.package_folder, "lib","pkgconfig")) - rm(self, "*.cmake", os.path.join(self.package_folder, "lib", "cmake", "libcmaes")) - copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) - - def package_info(self): - self.cpp_info.libs = ["cmaes"] - self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") - - self.cpp_info.requires.append("eigen::eigen") - - if self.options.openmp: - if self.settings.compiler in ["clang", "apple-clang"]: - self.cpp_info.requires.append("llvm-openmp::llvm-openmp") - openmp_flags = self._openmp_flags - self.cpp_info.cflags = openmp_flags - self.cpp_info.cxxflags = openmp_flags - self.cpp_info.sharedlinkflags = openmp_flags - self.cpp_info.exelinkflags = openmp_flags - - def validate(self): - if self.settings.compiler.cppstd: - check_min_cppstd(self, self._min_cppstd) \ No newline at end of file diff --git a/tools/conan/cmaes/patches/patch.diff b/tools/conan/cmaes/patches/patch.diff deleted file mode 100644 index ba728f3d..00000000 --- a/tools/conan/cmaes/patches/patch.diff +++ /dev/null @@ -1,142 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4a38212..dccfea4 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -6,12 +6,10 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") - endif () - --set(CMAKE_CXX_FLAGS "-Wall -Wextra") --set(CMAKE_CXX_FLAGS_DEBUG "-g") --set(CMAKE_CXX_FLAGS_RELEASE "-O3") -- - list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) - -+include(CompilerOptions) -+ - set (LIBCMAES_TOP_LEVEL NO) - if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) - set (LIBCMAES_TOP_LEVEL YES) -diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake -new file mode 100644 -index 0000000..af4f716 ---- /dev/null -+++ b/cmake/CompilerOptions.cmake -@@ -0,0 +1,91 @@ -+ -+set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} -Wall" -+) -+set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} -Wall ") -+ -+if(CMAKE_COMPILER_IS_GNUCXX) -+ set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} -Wextra") -+ set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wextra") -+endif(CMAKE_COMPILER_IS_GNUCXX) -+ -+if (MSVC) -+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_USE_MATH_DEFINES" ) -+ -+ set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} /permissive- /bigobj /w44101") -+ -+ set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} /permissive- /bigobj /Ox /w44101") -+ -+ set(MSVC_DISABLED_WARNINGS_LIST -+ "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not -+ # explicitly handled by a case label -+ # Disable this because it flags even when there is a default. -+ "C4068" -+ "C4100" # 'exarg' : unreferenced formal parameter -+ "C4127" # conditional expression is constant -+ "C4200" # nonstandard extension used : zero-sized array in -+ # struct/union. -+ "C4204" # nonstandard extension used: non-constant aggregate initializer -+ "C4221" # nonstandard extension used : 'identifier' : cannot be -+ # initialized using address of automatic variable -+ "C4242" # 'function' : conversion from 'int' to 'uint8_t', -+ # possible loss of data -+ "C4244" # 'function' : conversion from 'int' to 'uint8_t', -+ # possible loss of data -+ "C4245" # 'initializing' : conversion from 'long' to -+ # 'unsigned long', signed/unsigned mismatch -+ "C4251" -+ "C4267" # conversion from 'size_t' to 'int', possible loss of data -+ "C4275" -+ "C4355" -+ "C4371" # layout of class may have changed from a previous version of the -+ # compiler due to better packing of member '...' -+ "C4388" # signed/unsigned mismatch -+ "C4296" # '>=' : expression is always true -+ "C4350" # behavior change: 'std::_Wrap_alloc...' -+ "C4365" # '=' : conversion from 'size_t' to 'int', -+ # signed/unsigned mismatch -+ "C4389" # '!=' : signed/unsigned mismatch -+ "C4464" # relative include path contains '..' -+ "C4510" # 'argument' : default constructor could not be generated -+ "C4571" -+ "C4512" # 'argument' : assignment operator could not be generated -+ "C4514" # 'function': unreferenced inline function has been removed -+ "C4548" # expression before comma has no effect; expected expression with -+ # side-effect" caused by FD_* macros. -+ "C4610" # struct 'argument' can never be instantiated - user defined -+ # constructor required. -+ "C4619" -+ "C4623" # default constructor was implicitly defined as deleted -+ "C4625" # copy constructor could not be generated because a base class -+ # copy constructor is inaccessible or deleted -+ "C4626" # assignment operator could not be generated because a base class -+ # assignment operator is inaccessible or deleted -+ "C4643" -+ "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with -+ # '0' for 'directives' -+ # Disable this because GTest uses it everywhere. -+ "C4706" # assignment within conditional expression -+ "C4710" # 'function': function not inlined -+ "C4711" # function 'function' selected for inline expansion -+ "C4800" # 'int' : forcing value to bool 'true' or 'false' -+ # (performance warning) -+ "C4820" # 'bytes' bytes padding added after construct 'member_name' -+ "C4868" -+ "C4996" -+ "C5026" # move constructor was implicitly defined as deleted -+ "C5027" # move assignment operator was implicitly defined as deleted -+ "C5031" -+ "C5039" -+ "C5045" -+ ) -+ string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR -+ ${MSVC_DISABLED_WARNINGS_LIST}) -+ -+ set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") -+ endif() -diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h -index fb8b11d..6a6943b 100644 ---- a/include/libcmaes/eigenmvn.h -+++ b/include/libcmaes/eigenmvn.h -@@ -58,7 +58,20 @@ public: - static std::mt19937 rng; // The uniform pseudo-random algorithm - mutable std::normal_distribution norm; // gaussian combinator - -- EIGEN_EMPTY_STRUCT_CTOR(scalar_normal_dist_op) -+ scalar_normal_dist_op() = default; -+ scalar_normal_dist_op(const scalar_normal_dist_op& other) -+ : norm{other.norm} -+ { -+ rng = other.rng; -+ }; -+ scalar_normal_dist_op &operator=(const scalar_normal_dist_op &other) { -+ if(this != &other) -+ { -+ scalar_normal_dist_op temp(other); -+ swap(temp); -+ } -+ return *this; -+ }; - - scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) - { From fdec2fda786812c9c017a592b6554b6774f8cc26 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 11 Aug 2024 08:47:09 +0200 Subject: [PATCH 68/69] Add cmaes target --- conanfile.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conanfile.py b/conanfile.py index e1f0240b..64495f59 100644 --- a/conanfile.py +++ b/conanfile.py @@ -231,6 +231,14 @@ def package_info(self): self.cpp_info.components["Minimizer"].requires.append("nlopt::nlopt") + if self.options.UseLibCMAES: + self.cpp_info.components["cmaes"].libs = ["cmaes"] + self.cpp_info.components["cmaes"].set_property( + "cmake_target_name", "libcmaes::cmaes" + ) + self.cpp_info.components["Minimizer"].requires.append("cmaes") + + self.cpp_info.components["MinimumTracer"].libs = ["MinimumTracer"] self.cpp_info.components["MinimumTracer"].requires = [ "eigen::eigen", From aa031ab209bc1ba9a3af453aa0a85267495c2198 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 11 Aug 2024 09:44:29 +0200 Subject: [PATCH 69/69] run workflow without cmaes --- .github/workflows/conan.yml | 4 ++++ Setup.py | 2 -- src/minimizer/CMakeLists.txt | 2 +- tools/cmake/CMAES.cmake | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index 1ccf048d..201c7d3c 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -35,4 +35,8 @@ jobs: architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - name: Install conan run: pip install conan>2 + + - name: Build without cmaes + run: python3 Setup.py --create --build-missing --options UseLibCMAES=False + - run: python3 Setup.py --create --build-missing diff --git a/Setup.py b/Setup.py index 4270f173..3ce555ce 100644 --- a/Setup.py +++ b/Setup.py @@ -165,8 +165,6 @@ def conan_install( if build_missing: cmd += ["--build=missing"] - else: - cmd += ["--build=cmaes/0.10.0"] print(f"Executing command {cmd}") diff --git a/src/minimizer/CMakeLists.txt b/src/minimizer/CMakeLists.txt index db785af4..74472bb8 100644 --- a/src/minimizer/CMakeLists.txt +++ b/src/minimizer/CMakeLists.txt @@ -18,7 +18,7 @@ target_sources( if(cmaes_FOUND) add_subdirectory(LibCMAES) - target_link_libraries(Minimizer PUBLIC Minimizer_CMAES) + target_link_libraries(Minimizer PRIVATE Minimizer_CMAES) endif() if(NLopt_FOUND) diff --git a/tools/cmake/CMAES.cmake b/tools/cmake/CMAES.cmake index 80ac5f66..c820b73a 100644 --- a/tools/cmake/CMAES.cmake +++ b/tools/cmake/CMAES.cmake @@ -15,6 +15,7 @@ if(NOT libcmaes_FOUND) option(LIBCMAES_BUILD_PYTHON OFF) option(LIBCMAES_BUILD_EXAMPLES OFF) option(LIBCMAES_USE_OPENMP OpenMP_FOUND) + option(LIBCMAES_BUILD_SHARED_LIBS OFF) FetchContent_Populate(libcmaes) add_subdirectory(${libcmaes_SOURCE_DIR} ${libcmaes_BINARY_DIR}) include(GenerateExportHeader)