<commit_before>/*
 *  <NAME> (C) 2014
 *  
 *  This file acts as a driver for the various solvers.
 *  Since the solvers work on discrete input, unlimited sources are handled here.
 *  
 *  Segments = desired cuts of wood (WANT)
 *  Sources = known quatity stock (HAVE)
 *  Sources_unlim = unlimited quatity stock (HAVE)
 */


function descending_length(a, b) { return b.length - a.length; }

function run(job)
{

    //most solvers want these in descending size order
    job.sources.sort(descending_length);
    job.cuts.sort(descending_length);


    //TODO: resolve quantities of Infinity to actual counts

    var layout = null;

    switch(job.settings.mode)
    {
        default:
        case "auto": //Auto
            //TODO
            break;

        case "solve":
            layout = full_solve.run(job);
            break;

        case "fast_1":
            //TODO
            break;

        case "fast_2":
            //TODO
            break;
    }

    if(layout)
        return { success:true, data:convert_structure_patch(job, layout) };<commit_msg>better description for the rationale behind sorting the imputs<commit_after>/*
 *  <NAME> (C) 2014
 *  
 *  This file acts as a driver for the various solvers.
 *  Since the solvers work on discrete input, unlimited sources are handled here.
 *  
 *  Segments = desired cuts of wood (WANT)
 *  Sources = known quatity stock (HAVE)
 *  Sources_unlim = unlimited quatity stock (HAVE)
 */


function descending_length(a, b) { return b.length - a.length; }

function run(job)
{

    //having the solvers allocate the bigger cuts first will cause
    //boards to fill up faster, which rapidly disqualifies choices,
    //and helps speed the process along.
    job.sources.sort(descending_length);
    job.cuts.sort(descending_length);


    //TODO: resolve quantities of Infinity to actual counts

    var layout = null;

    switch(job.settings.mode)
    {
        default:
        case "auto": //Auto
            //TODO
            break;

        case "solve":
            layout = full_solve.run(job);
            break;

        case "fast_1":
            //TODO
            break;

        case "fast_2":
            //TODO
            break;
    }

    if(layout)
        return { success:true, data:convert_structure_patch(job, layout) };
{'fraction_non_alphanumeric': 0.09558823529411764, 'fraction_numerical': 0.005190311418685121, 'mean_word_length': 2.0963855421686746, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, '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': '3990363', 'n_tokens_mistral': 718, 'n_tokens_neox': 667, 'n_words': 217}