From f5cb0bc6f3d5bd7768a2b64da19f079ae9b2d5bd Mon Sep 17 00:00:00 2001 From: Geir Horn Date: Wed, 10 Jan 2024 16:26:09 +0100 Subject: [PATCH] First release of the solver component - Added build script - Fixed merge errors for the makefile - Extended the makefile header Change-Id: Icbf2d9f76ab0f13eea70796fef20422ecdb3e342 --- .vscode/c_cpp_properties.json | 34 +++++++++++++++++++--------- MakeSolver.sh | 39 ++++++++++++++++++++++++++++++++ MetricUpdater.hpp | 5 +++-- SolverComponent.cpp | 3 ++- makefile | 42 ++++++++++++++++++++++++++++++----- 5 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 MakeSolver.sh diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 6b6d476..d70a9a5 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -3,26 +3,40 @@ { "name": "Linux", "includePath": [ - "${default}", + "/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13", "/home/GHo/Documents/Code/CxxOpts/include", - "/usr/include", "/home/GHo/Documents/Code/Theron++", "/home/GHo/Documents/Code/Theron++/Utility", "/home/GHo/Documents/Code/Theron++/Communication", "/home/GHo/Documents/Code/Theron++/Communication/AMQ", - "/opt/AMPL/amplapi/include", + "/opt/AMPL/amplapi/include/ampl", "${workspaceFolder}/**" ], "defines": [], - "compilerArgs": [ - "--std=c++23", - "-I/opt/AMPL/amplapi/include", - "-I/usr/include" - ], "cStandard": "c23", - "cppStandard": "c++23", "intelliSenseMode": "linux-gcc-x64", - "compilerPath": "/usr/bin/g++" + "compilerPath": "/usr/bin/g++", + "compilerArgs": [ + "-std=c++23", + "-I/home/GHo/Documents/Code/Theron++", + "-I/home/GHo/Documents/Code/CxxOpts/include", + "-I/opt/AMPL/amplapi/include/ampl" + ], + "cppStandard": "c++23", + "compilerPathInCppPropertiesJson": "/usr/bin/g++", + "mergeConfigurations": false, + "configurationProvider": "ms-vscode.makefile-tools", + "browse": { + "path": [ + "/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13", + "/home/GHo/Documents/Code/Theron++", + "/home/GHo/Documents/Code/CxxOpts/include", + "/home/GHo/Documents/Code/Theron++/Utility", + "/home/GHo/Documents/Code/Theron++/Communication", + "/home/GHo/Documents/Code/Theron++/Examples" + ], + "limitSymbolsToIncludedHeaders": false + } } ], "version": 4 diff --git a/MakeSolver.sh b/MakeSolver.sh new file mode 100644 index 0000000..db9682d --- /dev/null +++ b/MakeSolver.sh @@ -0,0 +1,39 @@ +#!/usr/bin/bash +# ============================================================================== +# +# Solver Component +# +# This script will build the Solver Component on an 'empty' machine with +# minimal installation of the latest Fedora version. The intent is to load +# all dependencies in a constructive way. +# +# Author and Copyright: Geir Horn, University of Oslo +# Contact: Geir.Horn@mn.uio.no +# License: MPL2.0 (https://www.mozilla.org/en-US/MPL/2.0/) +# ============================================================================== + +# Installing the development framework for the distribution + +dnf --assumeyes group 'Development Tools' +dnf --assumeyes install ccache qpid-proton-cpp* json-devel coin-or-Couenne + +# Cloning the open source dependencies + +mkdir Externals +cd Externals +git clone https://github.com/jarro2783/cxxopts.git CxxOpts +git clone https://github.com/GeirHo/TheronPlusPlus.git Theron++ +cd + +# Installing the AMPL library + +wget https://portal.ampl.com/external/?url=\ +https://portal.ampl.com/dl/amplce/ampl.linux64.tgz +tar --file=ampl.linux64.tgz --extract --directory=Externals/AMPL +cp ampl.lic Externals/AMPL + +# Building the solver component + +make SolverComponent -e THERON=Externals/Theron++ \ +AMPL_INCLUDE=Externals/AMPL/amplapi/include AMPL_LIB=Externals/AMPL/amplapi/lib\ +CxxOpts_DIR=Externals/CxxOpts/include diff --git a/MetricUpdater.hpp b/MetricUpdater.hpp index 5eada0e..d4fcf1c 100644 --- a/MetricUpdater.hpp +++ b/MetricUpdater.hpp @@ -87,7 +87,8 @@ constexpr std::string_view TimePoint = "predictionTime"; // application execution context as published by the Optimiser Controller is // defined next. -constexpr std::string_view MetricSubscriptions = "ApplicationContext"; +constexpr std::string_view MetricSubscriptions + = "eu.nebulouscloud.optimiser.solver.metrics"; // The metric value messages will be published on different topics and to // check if an inbound message is from a metric value topic, it is necessary @@ -126,7 +127,7 @@ constexpr std::string_view ObjectiveFunctionName = "ObjectiveFunction"; // should follow some standard topic convention. constexpr std::string_view SLOViolationTopic - = "eu.nebulouscloud.optimiser.slo.violation"; + = "eu.nebulouscloud.optimiser.solver.slo"; /*============================================================================== diff --git a/SolverComponent.cpp b/SolverComponent.cpp index 8f85fe9..2945dd8 100644 --- a/SolverComponent.cpp +++ b/SolverComponent.cpp @@ -67,7 +67,8 @@ License: MPL2.0 (https://www.mozilla.org/en-US/MPL/2.0/) #include "Communication/AMQ/AMQEndpoint.hpp" // The AMP endpoint #include "Communication/AMQ/AMQjson.hpp" // Transparent JSON-AMQP -// The cxxopts command line options parser +// The cxxopts command line options parser that can be cloned from +// https://github.com/jarro2783/cxxopts #include "cxxopts.hpp" diff --git a/makefile b/makefile index db988a2..b804975 100644 --- a/makefile +++ b/makefile @@ -5,6 +5,23 @@ # The NebulOuS solver consists of several interacting actors using the AMQ # interface of the Theron++ framework. # +# The following packages should be available on Fedora prior to compiling +# the file +# +# ccache # for effcient C++ compilations +# qpid-proton-cpp* # Qpid Proton Active Message Queue protocol API +# json-devel # Niels Lohmann's JSON library +# coin-or-Couenne # The solver to be used by AMPL +# +# In addtition the problem is formuated using A Mathematical Programming +# Language (AMPL) and so it should be installed from +# https://portal.ampl.com/user/ampl/request/amplce/trial/new +# +# There are source code dependencies that should be cloned to local disk +# +# Theron++ # https://github.com/GeirHo/TheronPlusPlus.git +# cxxopts # https://github.com/jarro2783/cxxopts.git +# # Author and Copyright: Geir Horn, University of Oslo # Contact: Geir.Horn@mn.uio.no # License: MPL2.0 (https://www.mozilla.org/en-US/MPL/2.0/) @@ -14,25 +31,40 @@ # Defining compiler and commands # -CC = g++ +CC = ccache g++ #CC = clang++ RM = rm -f +#------------------------------------------------------------------------------ +# Paths +#------------------------------------------------------------------------------ +# +# The default values of the paths are given here to be overridden by build +# definitions on the command line for creating the component container. +# # Location of the Theron++ framework relative to this make file and the code -THERON = /home/GHo/Documents/Code/Theron++ +THERON ?= /home/GHo/Documents/Code/Theron++ # Location of the AMPL API directory -AMPL_INCLUDE = /opt/AMPL/amplapi/include +AMPL_INCLUDE ?= /opt/AMPL/amplapi/include + +# Location of the library directory + +AMPL_LIB ?= /opt/AMPL/amplapi/lib # The solver component uses the CxxOpts class for parsing the command line # options since it is header only and lighter than the Options library of # boost, which seems to have lost the most recent C++ features. The CxxOpts # library can be cloned from https://github.com/jarro2783/cxxopts -CxxOpts_DIR = /home/GHo/Documents/Code/CxxOpts/include +CxxOpts_DIR ?= /home/GHo/Documents/Code/CxxOpts/include +#------------------------------------------------------------------------------ +# Options for the compiler and linker +#------------------------------------------------------------------------------ +# # Optimisation -O3 is the highest level of optimisation and should be used # with production code. -Og is the code optimising and offering debugging # transparency and should be use while the code is under development @@ -67,7 +99,7 @@ CXXFLAGS = $(GENERAL_OPTIONS) $(INCLUDE_DIRECTORIES) $(DEPENDENCY_FLAGS) \ CFLAGS = $(DEPENDENCY_FLAGS) $(OPTIMISATION_FLAG) $(GENERAL_OPTIONS) LDFLAGS = -fuse-ld=gold -ggdb -D_DEBUG -pthread -l$(THERON)/Theron++.a \ - -lqpid-proton-cpp -l/opt/AMPL/amplapi/lib/libampl.so + -lqpid-proton-cpp -l$(AMPL_LIB)/libampl.so #------------------------------------------------------------------------------ # Theron library