meow
commit
a220477446
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "lib/blt-with-graphics"]
|
||||||
|
path = lib/blt-with-graphics
|
||||||
|
url = https://git.tpgc.me/tri11paragon/BLT-With-Graphics-Template
|
|
@ -0,0 +1,79 @@
|
||||||
|
cmake_minimum_required(VERSION 3.25)
|
||||||
|
|
||||||
|
macro(sanitizers target_name)
|
||||||
|
if (${ENABLE_ADDRSAN} MATCHES ON)
|
||||||
|
target_compile_options(${target_name} PRIVATE -fsanitize=address)
|
||||||
|
target_link_options(${target_name} PRIVATE -fsanitize=address)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (${ENABLE_UBSAN} MATCHES ON)
|
||||||
|
target_compile_options(${target_name} PRIVATE -fsanitize=undefined)
|
||||||
|
target_link_options(${target_name} PRIVATE -fsanitize=undefined)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (${ENABLE_TSAN} MATCHES ON)
|
||||||
|
target_compile_options(${target_name} PRIVATE -fsanitize=thread)
|
||||||
|
target_link_options(${target_name} PRIVATE -fsanitize=thread)
|
||||||
|
endif ()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(compile_options target_name)
|
||||||
|
if (NOT ${MOLD} STREQUAL MOLD-NOTFOUND)
|
||||||
|
target_compile_options(${target_name} PUBLIC -fuse-ld=mold)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic -Wno-comment)
|
||||||
|
target_link_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic -Wno-comment)
|
||||||
|
sanitizers(${target_name})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(blt_add_project name source type)
|
||||||
|
|
||||||
|
project(${name}-${type})
|
||||||
|
|
||||||
|
add_executable(${name}-${type} ${source})
|
||||||
|
|
||||||
|
target_link_libraries(${name}-${type} PRIVATE BLT blt-gp Threads::Threads)
|
||||||
|
|
||||||
|
compile_options(${name}-${type})
|
||||||
|
target_compile_definitions(${name}-${type} PRIVATE BLT_DEBUG_LEVEL=${DEBUG_LEVEL})
|
||||||
|
|
||||||
|
if (${TRACK_ALLOCATIONS})
|
||||||
|
target_compile_definitions(${name}-${type} PRIVATE BLT_TRACK_ALLOCATIONS=1)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_test(NAME ${name} COMMAND ${name}-${type})
|
||||||
|
|
||||||
|
set_property(TEST ${name} PROPERTY FAIL_REGULAR_EXPRESSION "FAIL;ERROR;FATAL;exception")
|
||||||
|
|
||||||
|
project(schedulizer)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
project(schedulizer VERSION 0.0.1)
|
||||||
|
|
||||||
|
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||||
|
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||||
|
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
|
||||||
|
option(BUILD_SCHEDULIZER_EXAMPLES "Build example programs. This will build with CTest" OFF)
|
||||||
|
option(BUILD_SCHEDULIZER_TESTS "Build test programs. This will build with CTest" OFF)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
add_subdirectory(lib/blt-with-graphics)
|
||||||
|
|
||||||
|
include_directories(include/)
|
||||||
|
file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||||
|
|
||||||
|
add_executable(schedulizer ${PROJECT_BUILD_FILES})
|
||||||
|
|
||||||
|
compile_options(schedulizer)
|
||||||
|
|
||||||
|
target_link_libraries(schedulizer PRIVATE BLT_WITH_GRAPHICS)
|
||||||
|
|
||||||
|
if (${BUILD_SCHEDULIZER_EXAMPLES})
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (BUILD_SCHEDULIZER_TESTS)
|
||||||
|
|
||||||
|
endif()
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 1808af68b55e6bbcbc8ce82dcccbe12c21a7b38a
|
|
@ -0,0 +1,111 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <blt/parse/argparse_v2.h>
|
||||||
|
#include <blt/std/types.h>
|
||||||
|
#include <blt/std/random.h>
|
||||||
|
|
||||||
|
constexpr blt::i32 SHIFTS_PER_WEEK = 5;
|
||||||
|
constexpr blt::i32 POPULATION_SIZE = 100;
|
||||||
|
|
||||||
|
enum class shift_t : blt::u8
|
||||||
|
{
|
||||||
|
NONE, AMs, PMs
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class weekday_t : blt::u8
|
||||||
|
{
|
||||||
|
SATURDAY,
|
||||||
|
SUNDAY,
|
||||||
|
MONDAY,
|
||||||
|
TUESDAY,
|
||||||
|
WEDNESDAY,
|
||||||
|
THURSDAY,
|
||||||
|
FRIDAY
|
||||||
|
};
|
||||||
|
|
||||||
|
bool days_require_pair(const weekday_t day)
|
||||||
|
{
|
||||||
|
switch (day)
|
||||||
|
{
|
||||||
|
case weekday_t::SATURDAY:
|
||||||
|
case weekday_t::SUNDAY:
|
||||||
|
return true;
|
||||||
|
case weekday_t::MONDAY:
|
||||||
|
case weekday_t::TUESDAY:
|
||||||
|
case weekday_t::WEDNESDAY:
|
||||||
|
case weekday_t::THURSDAY:
|
||||||
|
case weekday_t::FRIDAY:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BLT_UNREACHABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct placement_t
|
||||||
|
{
|
||||||
|
shift_t shift;
|
||||||
|
bool invariant;
|
||||||
|
|
||||||
|
explicit placement_t(const shift_t shift, const bool invariant = false) : shift{shift}, invariant{invariant}
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct day_t
|
||||||
|
{
|
||||||
|
placement_t brett{shift_t::PMs, true};
|
||||||
|
placement_t kayda;
|
||||||
|
placement_t tim;
|
||||||
|
placement_t braeden;
|
||||||
|
|
||||||
|
weekday_t day;
|
||||||
|
|
||||||
|
[[nodiscard]] bool days_require_pair() const
|
||||||
|
{
|
||||||
|
return ::days_require_pair(day);
|
||||||
|
}
|
||||||
|
|
||||||
|
day_t(const placement_t& kayda, const placement_t& tim, const placement_t& braeden, const weekday_t day) : kayda{kayda},
|
||||||
|
tim{tim},
|
||||||
|
braeden{braeden},
|
||||||
|
day{day}
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct week_t
|
||||||
|
{
|
||||||
|
day_t days[7];
|
||||||
|
|
||||||
|
explicit week_t(const day_t days[7]): days{}
|
||||||
|
{
|
||||||
|
std::memcpy(this->days, days, sizeof(day_t) * 7);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class shift_solver_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static placement_t
|
||||||
|
|
||||||
|
static day_t generate_random_day(const weekday_t day)
|
||||||
|
{
|
||||||
|
auto& random = get_random();
|
||||||
|
std::array<placement_t, 3> placements{};
|
||||||
|
if (days_require_pair(day))
|
||||||
|
{
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static blt::random::random_t& get_random()
|
||||||
|
{
|
||||||
|
thread_local blt::random::random_t random{691};
|
||||||
|
return random;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "Hello World!" << std::endl;
|
||||||
|
}
|
Loading…
Reference in New Issue