/* 
 * File:   main.cpp
 * Author: lubajz
 *
 * Created on 12. prosinec 2009, 12:28
 */

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

/*#include <unistd.h> //pridano
#include <sys/wait.h>
#include <spawn.h>*/
#include <unistd.h>

#include "GAMSInOut.h"
#include "Exceptions.h"

/*
 * 
 */
int main(int argc, char** argv) {
    int nVariables = 2;

    try {
        SCENARIOS S("dataparaboly.txt", nVariables);
        S.printAllScenarios();
        S.checkIntegrity(1e-7);
        PHA P(&S, "paraboly.gms", 1e-9, 3);
        P.runPHA();






 /*       S.scenarios[0]->weights->data[0] = 1.11;
        S.averageSolution->data[1] = 2.055;
        S.printAllScenarios();
        S.checkIntegrity(1e-7);
        S.makeGAMSSourceFiles("nutricniproblem.gms");

// pokusy se spoustenim a cekanim

        //printf("run mpi\n");
        //getchar();
        //system("gnome-terminal --execute mpirun -np 5 parallelGAMSrun");

        //sleep(5);


       
   //     printf("zastaveno");
  //      getchar();

// konec pokusu
     

        MATRIX m(3, 3);
        VECTOR v(2);
        SCALAR s(0);

        S.readMatrixDataFromLSTFile("scenario1.lst", "x", m);
        m.printMatrix();

        S.readVectorDataFromLSTFile("scenario1.lst", "y", v);
        v.printVector();
        
        S.readObjValueFromLSTFile("scenario1.lst", "z", s);
        s.printScalar();
*/
      
    }
    catch (SumProbabilitiesException e) {
        e.displayMessage();
    }
    catch (NumParametersException e) {
        e.displayMessage();
    }
    catch (FileNotExists e) {
        e.displayMessage();
    }
    catch (NoOccurenceOfVariableInLSTFile e) {
        e.displayMessage();
    }
    catch (GeneralException e){
        e.displayMessage();
    }
    catch(...) {
        printf(" > ERROR! An unspecified exception occured.");
    }
    
    return (EXIT_SUCCESS);
}

