/**
 * @file main.cpp
 * @author Jan Holan, xholan11
 * @brief file for testing created library
 * @version 0.1
 * @date 2022-12-10
 *
 * @copyright Copyright (c) 2022
 *
 */

#include <iostream>
#include <fstream>
#include <istream>
#include <vector>
#include <list>

#include "./../src/WarehousePickingOpt.h"
#include "./../src/warehouse_picking_opt_debug.h"
#include <filesystem>
#include <nlohmann/json.hpp>

using namespace std;
using json = nlohmann::json;

int main()
{
    // enable/disable debug info
    is_debug_on = true;

    // configure the solver --------------------------------------------------
    SolverConfiguration sc = SolverConfiguration(
        BPAlgorithms::FFD_1D_ORDER_ITEMS_SPLIT_ONE_BOX_TYPE,
        GroupingCustomersAlgorithms::AVG_DISTANCES,
        ShortestPathAlgorithms::GREEDY);

    BoxConfiguration bc;
    bc.addBox(Box(28.0, 29.0, 45.0, 4000, "masterBox"), 1000);

    CartConfiguration cc = CartConfiguration(90, 200, 50, 1, 3);

    Warehouse w;
    CartsLoader CL(w);
    //----------------------------------------------------------------------------------------------------

    /*********************/
    /*******TEST 1********/
    /*********************/
    // iterate through all the files in data/data_both and create carts for each of the file
    for (auto fd : filesystem::directory_iterator("./../data/data_both"))
    {
        cout << fd.path() << endl;
        CL.loadItemsAndSpec(fd.path());
        cout << "LIBRARY RESULT: " << endl;
        CL.loadingCartsRun(sc, cc, bc);
        cout << "COMPANY RESULT: " << endl; 
        CL.testUsedData(fd.path());
        cout << endl
             << "***" << endl;
    }

    /*********************/
    /*******TEST 2********/
    /*********************/
    // run the cart creating for one wave and export the output data

    string path = "./../data/data_both/wave1422307.json";
    CL.loadItemsAndSpec(path);
    CL.loadingCartsRun(sc, cc, bc);
    ofstream o("out.json");
    o << CL.exportCartsToJson() << endl;

    return 0;
}
