<commit_before>// -*- mode: c++; coding: utf-8 -*-
/*! @file tissue.cpp
    @brief Implementation of Tissue class
*/
#include "tissue.hpp"

#include <cstdlib>
#include <cassert>
#include <iostream>
#include <sstream>

#include <boost/program_options.hpp>

#include <cxxwtils/prandom.hpp>
#include <cxxwtils/iostr.hpp>
#include <cxxwtils/gz.hpp>
#include <cxxwtils/debug.hpp>
#include <cxxwtils/algorithm.hpp>


size_t Tissue::DIMENSIONS_ = 3;
std::string Tissue::COORDINATE_ = "moore";
std::string Tissue::PACKING_ = "push";
double Tissue::SIGMA_E_ = std::numeric_limits<double>::infinity();
size_t Tissue::INITIAL_SIZE_ = 1;
size_t Tissue::MAX_SIZE_ = 16384;

//! Program options
/*! @return Program options description

    Command line option | Symbol         | Variable
    --------------------| -------------- | -------------------------
    `-D,--dimensions`   | -              | Tissue::DIMENSIONS_
    `-C,--coord`        | -              | Tissue::COORDINATE_
    `-P,--packing`      | -              | Tissue::PACKING_
    `-g,--peripheral`   | \f$\sigma_E\f$ | Tissue::SIGMA_E_
    `-O,--origin`       | -              | Tissue::INITIAL_SIZE_
    `-N,--max`          | -              | Simulation::MAX_SIZE
*/
boost::program_options::options_description& Tissue::opt_description() {
    namespace po = boost::program_options;
    static po::options_description desc{"Tissue"};
    desc.add_options()
        ("dimensions,D", po::value<size_t>(&DIMENSIONS_)->default_value(DIMENSIONS_))
        ("coord,C", po::value<std::string>(&COORDINATE_)->default_value(COORDINATE_))
        ("packing,P", po::value<std::string>(&PACKING_)->default_value(PACKING_))
        ("peripheral,g", po::value<double>(&SIGMA_E_)->default_value(SIGMA_E_))
        ("origin,O", po::value<size_t>(&INITIAL_SIZE_)->default_value(INITIAL_SIZE_))
        ("max,N", po::value<size_t>(&MAX_SIZE_)->default_value(MAX_SIZE_))
    ;
    return desc;
}

Tissue::Tissue() {
    if (COORDINATE_ == "neumann") {coord_func_ = std::make_unique<Neumann>(DIMENSIONS_);}
    else if (COORDINATE_ == "moore") {coord_func_ = std::make_unique<Moore>(DIMENSIONS_);}
    else if (COORDINATE_ == "hex") {coord_func_ = std::make_unique<Hexagonal>(DIMENSIONS_);}
    (specimens_ = wtl::make_oss()) << header();
    (snapshots_ = wtl::make_oss()) << header();
    (drivers_ = wtl::make_oss()) << "id\ttype\tcoef\n";
    for (const auto& coord: coord_func_->sphere(INITIAL_SIZE_)) {
        auto x = std::make_shared<Cell>(coord, ++id_tail_);
        tumor_.insert(x);
        queue_push(x->delta_time(positional_value(x->coord())), x);
    }
}

bool Tissue::grow(const size_t max_size) {HERE;
    snap(snapshots_);
    bool taking_snapshots = true;
    size_t i = 0;
    while (tumor_.size() < max_size) {
        if ((++i % 256) == 0) {derr("  " << tumor_.size() << "\r");}
        auto it = queue_.begin();
        time_ = it->first;
        const auto mother = it->second;
        queue_.erase(it);
        if (mother->next_event() == Event::birth) {
            const auto daughter = std::make_shared<Cell>(*mother);
            if (insert(daughter)) {<commit_msg>Minor change in debug print<commit_after>// -*- mode: c++; coding: utf-8 -*-
/*! @file tissue.cpp
    @brief Implementation of Tissue class
*/
#include "tissue.hpp"

#include <cstdlib>
#include <cassert>
#include <iostream>
#include <sstream>

#include <boost/program_options.hpp>

#include <cxxwtils/prandom.hpp>
#include <cxxwtils/iostr.hpp>
#include <cxxwtils/gz.hpp>
#include <cxxwtils/debug.hpp>
#include <cxxwtils/algorithm.hpp>


size_t Tissue::DIMENSIONS_ = 3;
std::string Tissue::COORDINATE_ = "moore";
std::string Tissue::PACKING_ = "push";
double Tissue::SIGMA_E_ = std::numeric_limits<double>::infinity();
size_t Tissue::INITIAL_SIZE_ = 1;
size_t Tissue::MAX_SIZE_ = 16384;

//! Program options
/*! @return Program options description

    Command line option | Symbol         | Variable
    --------------------| -------------- | -------------------------
    `-D,--dimensions`   | -              | Tissue::DIMENSIONS_
    `-C,--coord`        | -              | Tissue::COORDINATE_
    `-P,--packing`      | -              | Tissue::PACKING_
    `-g,--peripheral`   | \f$\sigma_E\f$ | Tissue::SIGMA_E_
    `-O,--origin`       | -              | Tissue::INITIAL_SIZE_
    `-N,--max`          | -              | Simulation::MAX_SIZE
*/
boost::program_options::options_description& Tissue::opt_description() {
    namespace po = boost::program_options;
    static po::options_description desc{"Tissue"};
    desc.add_options()
        ("dimensions,D", po::value<size_t>(&DIMENSIONS_)->default_value(DIMENSIONS_))
        ("coord,C", po::value<std::string>(&COORDINATE_)->default_value(COORDINATE_))
        ("packing,P", po::value<std::string>(&PACKING_)->default_value(PACKING_))
        ("peripheral,g", po::value<double>(&SIGMA_E_)->default_value(SIGMA_E_))
        ("origin,O", po::value<size_t>(&INITIAL_SIZE_)->default_value(INITIAL_SIZE_))
        ("max,N", po::value<size_t>(&MAX_SIZE_)->default_value(MAX_SIZE_))
    ;
    return desc;
}

Tissue::Tissue() {
    if (COORDINATE_ == "neumann") {coord_func_ = std::make_unique<Neumann>(DIMENSIONS_);}
    else if (COORDINATE_ == "moore") {coord_func_ = std::make_unique<Moore>(DIMENSIONS_);}
    else if (COORDINATE_ == "hex") {coord_func_ = std::make_unique<Hexagonal>(DIMENSIONS_);}
    (specimens_ = wtl::make_oss()) << header();
    (snapshots_ = wtl::make_oss()) << header();
    (drivers_ = wtl::make_oss()) << "id\ttype\tcoef\n";
    for (const auto& coord: coord_func_->sphere(INITIAL_SIZE_)) {
        auto x = std::make_shared<Cell>(coord, ++id_tail_);
        tumor_.insert(x);
        queue_push(x->delta_time(positional_value(x->coord())), x);
    }
}

bool Tissue::grow(const size_t max_size) {HERE;
    snap(snapshots_);
    bool taking_snapshots = true;
    size_t i = 0;
    while (tumor_.size() < max_size) {
        if ((++i % 256) == 0) {derr("\r" << tumor_.size());}
        auto it = queue_.begin();
        time_ = it->first;
        const auto mother = it->second;
        queue_.erase(it);
        if (mother->next_event() == Event::birth) {
            const auto daughter = std::make_shared<Cell>(*mother);
            if (insert(daughter)) {
{'fraction_non_alphanumeric': 0.19284802043422733, 'fraction_numerical': 0.004150702426564496, 'mean_word_length': 3.190635451505017, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3453138', 'n_tokens_mistral': 2274, 'n_tokens_neox': 2161, 'n_words': 361}