/* 
 * File:   GAMSInOut.h
 * Author: lubajz
 *
 * Created on 12. prosinec 2009, 12:29
 */

#include "DataContainers.h"

#ifndef _GAMSINOUT_H
#define	_GAMSINOUT_H

class SCENARIOS;

class PHA {
public:
    SCENARIOS * S;
    char * templet;
    double eps, rho;
    PHA(SCENARIOS *, char *, double, double);
    void runPHA(void);
    void runGAMSinParallel(void);
};

class SCENARIO {
public:
    double * data;
    VECTOR * weights;   // w(s)
    VECTOR * solution;  // x^j(s)
    int numParameters;
    double probability;
    SCENARIO(int);
    SCENARIO(SCENARIO &);
    ~SCENARIO();
private:
};

class SCENARIOS {
public:
    SCENARIO ** scenarios;
    VECTOR * averageSolution;
    VECTOR * oldAverageSolution;
    int numScenarios;
    int numParameters;
    int numVariables;
    double rho;
    SCENARIOS(char*, int);
    ~SCENARIOS();
    void checkInfeasibility(char *, int);
    void updateAllWeights(double);
    void printAllScenarioSolutions(void);
    void saveAllScenarioSolutionsToFile(int, double, char *);
    void loadAllScenarioSolutionsFromLSTFiles(void);
    double calcTerminationCondition(void);
    void calcAverageSolution(void);
    void readScenarioFromLine(SCENARIO *, char*);
    void loadScenariosSettingFromFile(char*);
    void printAllScenarios(void);
    void checkIntegrity(double);
    void makeGAMSSourceFiles(char*);
    static void readMatrixDataFromLSTFile(char * sourceFile, char * nameOfVariable, MATRIX & m);
    static void readVectorDataFromLSTFile(char * sourceFile, char * nameOfVariable, VECTOR & v);
    static void readObjValueFromLSTFile(char * sourceFile, char * nameOfVariable, SCALAR & s);
private:
};

double calcSquareOfVectors(VECTOR *, VECTOR *);

#endif	/* _GAMSINOUT_H */

