<commit_before>#include <cuda_runtime.h>
#include <stdio.h>
#include <boost/program_options.hpp>
#include <cmath>
#include <random>
#include "common.h"
#include "tee.h"
#include "non_cache.h"
#include "non_cache_gpu.h"
#include "model.h"
#include "curl.h"
#include "weighted_terms.h"
#include "custom_terms.h"
#include "precalculate_gpu.h"
#include "gpucode.h"

//TODO: logging, user-provided random seed

void make_mol(std::vector<atom_params>& atoms, std::vector<smt>& types, 
             std::mt19937 engine,
             size_t natoms=0, size_t min_atoms=1, size_t max_atoms=200, 
             float max_x=25, float max_y=25, float max_z=25) {

    if (!natoms) {
    //if not provided, randomly generate the number of atoms
        std::uniform_int_distribution<int> natoms_dist(min_atoms, max_atoms+1);
        natoms = natoms_dist(engine);
    }

    //randomly seed reasonable-ish coordinates and types
    //TODO: get charge from type?
    std::uniform_real_distribution<float> coords_dists[3];
    coords_dists[0] = std::uniform_real_distribution<float>(-25, std::nextafter(max_x, FLT_MAX));
    coords_dists[1] = std::uniform_real_distribution<float>(-25, std::nextafter(max_y, FLT_MAX));
    coords_dists[2] = std::uniform_real_distribution<float>(-25, std::nextafter(max_z, FLT_MAX));
    std::uniform_int_distribution<int> charge_dist(-2, 3);
    std::uniform_int_distribution<int> type_dist(0, smina_atom_type::NumTypes-1);

    //set up vector of atoms as well as types
    for (size_t i=0; i<natoms; ++i) {
        atom_params atom;
        atom.charge = charge_dist(engine);
        for (size_t j=0; j<3; ++j) 
            atom.coords[j] = coords_dists[j](engine);
        atoms.push_back(atom);
        atoms[i].charge = charge_dist(engine);
        types.push_back(static_cast<smt>(type_dist(engine)));
    }
}

int main() {
    //TODO: include progress bar?
    //set up program options
    std::string logname("log.test");
    auto seed = std::random_device()();
    namespace po = boost::program_options;
    po::options_description inputs("Input");
    inputs.add_options()
        ("seed,s", po::value<unsigned>(&seed), "seed for random number generator")
        ("log", po::value<std::string>(&logname), "specify logfile, default is log.test");
    po::options_description desc, desc_simple;
    desc.add(inputs);
    desc_simple.add(inputs);

    seed = 0;
    //set up c++11 random number engine
    std::mt19937 engine(seed);

    //set up logging
    bool quiet = true;
    tee log(quiet);
    log.init(logname);
    // log << "test" << "\n";

    //set up scoring function
    custom_terms t;
	t.add("gauss(o=0,_w=0.5,_c=8)", -0.035579);
	t.add("gauss(o=3,_w=2,_c=8)", -0.005156);
	t.add("repulsion(o=0,_c=8)", 0.840245);
	t.add("hydrophobic(g=0.5,_b=1.5,_c=8)", -0.035069);
	t.add("non_dir_h_bond(g=-0.7,_b=0,_c=8)", -0.587439);<commit_msg>commandline args work but the program doesn't<commit_after>#include <cuda_runtime.h>
#include <stdio.h>
#include <boost/program_options.hpp>
#include <cmath>
#include <random>
#include "common.h"
#include "tee.h"
#include "non_cache.h"
#include "non_cache_gpu.h"
#include "model.h"
#include "curl.h"
#include "weighted_terms.h"
#include "custom_terms.h"
#include "precalculate_gpu.h"
#include "gpucode.h"

//TODO: logging, user-provided random seed

void make_mol(std::vector<atom_params>& atoms, std::vector<smt>& types, 
             std::mt19937 engine,
             size_t natoms=0, size_t min_atoms=1, size_t max_atoms=200, 
             float max_x=25, float max_y=25, float max_z=25) {

    if (!natoms) {
    //if not provided, randomly generate the number of atoms
        std::uniform_int_distribution<int> natoms_dist(min_atoms, max_atoms+1);
        natoms = natoms_dist(engine);
    }

    //randomly seed reasonable-ish coordinates and types
    //TODO: get charge from type?
    std::uniform_real_distribution<float> coords_dists[3];
    coords_dists[0] = std::uniform_real_distribution<float>(-25, std::nextafter(max_x, FLT_MAX));
    coords_dists[1] = std::uniform_real_distribution<float>(-25, std::nextafter(max_y, FLT_MAX));
    coords_dists[2] = std::uniform_real_distribution<float>(-25, std::nextafter(max_z, FLT_MAX));
    std::uniform_int_distribution<int> charge_dist(-2, 3);
    std::uniform_int_distribution<int> type_dist(0, smina_atom_type::NumTypes-1);

    //set up vector of atoms as well as types
    for (size_t i=0; i<natoms; ++i) {
        atom_params atom;
        atom.charge = charge_dist(engine);
        for (size_t j=0; j<3; ++j) 
            atom.coords[j] = coords_dists[j](engine);
        atoms.push_back(atom);
        atoms[i].charge = charge_dist(engine);
        types.push_back(static_cast<smt>(type_dist(engine)));
    }
}

int main(int argc, char* argv[]) {
    //TODO: include progress bar?
    //set up program options
    std::string logname;
    unsigned seed;
    namespace po = boost::program_options;
	po::positional_options_description positional; // remains empty
    po::options_description inputs("Input");
    inputs.add_options()
        ("seed,s", po::value<unsigned>(&seed), "seed for random number generator")
        ("log", po::value<std::string>(&logname), "specify logfile, default is test.log");
    po::options_description desc, desc_simple;
    desc.add(inputs);
    desc_simple.add(inputs);
    po::variables_map vm;
    try
    {
        po::store(
                po::command_line_parser(argc, argv).options(desc)
                .style(
                    po::command_line_style::default_style
                    ^ po::command_line_style::allow_guessing)
                .positional(positional).run(), vm);
        notify(vm);
    } catch (po::error& e)
    {
		std::cerr << "Command line parse error: " << e.what() << '\n'
				<< "\nCorrect usage:\n" << desc_simple << '\n';
		return 1;
	}
    if (!vm.count("seed"))
        seed = std::random_device()();
    if (!vm.count("logname"))
        logname = "test.log";
    //set up c++11 random number engine
    std::mt19937 engine(seed);

    //set up logging
    bool quiet = true;
    tee log(quiet);
    log.init(logname);
    // log << "test" << "\n";

    //set up scoring function
    custom_terms t;
	t.add("gauss(o=0,_w=0.5,_c=8)", -0.035579);
	t.add("gauss(o=3,_w=2,_c=8)", -0.005156);
	t.add("repulsion(o=0,_c=8)", 0.840245);
	t.add("hydrophobic(g=0.5,_b=1.5,_c=8)", -0.035069);
	t.add("non_dir_h_bond(g=-0.7,_b=0,_c=8)", -0.587439);
{'fraction_non_alphanumeric': 0.16046511627906976, 'fraction_numerical': 0.02945736434108527, 'mean_word_length': 3.6144492131616595, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 37, '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': '2859296', 'n_tokens_mistral': 2450, 'n_tokens_neox': 2315, 'n_words': 461}