<reponame>alex-cornejo/pdisp_ckc<filename>main.cpp
/*
 File       : main.cpp
 Project    : Heuristic for CVPCP
 Developer  : <NAME>
 Date       : Nov 13 2013
 Institution: PISIS - FIME - UANL
 */


#include "global.h"
#include "readInstance.h"
#include "IGVND.h"

using namespace std;

int main(int argc, const char *argv[]) {
    if (argc < 5) {
        cout << "Missing parameters.\n";
        return -1;
    }
//    cout << argv[1] << endl;
    if (!read(argv[1])) {
        cout << "File not found.\n";
        return -1;
    }

    r_max = atoi(argv[2]);
    alpha = atof(argv[3]);
    e = atoi(argv[4]);

    int iterations = atoi(argv[6]);

    time_start = getCPUTime();
    // start time
    clock_t begin = clock();

//    seed = get_seed();
    seed = 0;
    solution best;
    for (int i = 0; i < iterations; ++i) {
        srand(seed++);

        result = IGVND(r_max, alpha, e, 0, 0, 0);
        if (i == 0 || result.f < best.f) {
            best = result;
        }
    }

    time_stop = getCPUTime();
    // finish time
    clock_t end = clock();
    double time_spent = (double) (end - begin) / CLOCKS_PER_SEC;

    result = best;

    // print(result);
    cout << result.f <<","<<time_spent/iterations<< endl;

//    if (argc > 5)
//        save(argv[5], result);

    // print solution in console
//    for (int k = 0; k < p; ++k) {
//        cout << result.P[k];
//        cout << " |";
//        for (auto j = result.X[k].begin(); j != result.X[k].end(); ++j) {
//            cout << " ";
//            cout << *j;
//        }
//        cout << "\n";
//    }

    finalize();

    return 0;
}
