/* 
 * 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(double, int);
    void runGAMSinParallel(int);
};

class SCENARIO {
public:
    double * data;
    VECTOR * weights1; // w_1(s)
    VECTOR * weights2; // w_2(s)
    VECTOR * solution1;  // x^j_1(s)
    VECTOR * solution2;  // x^j_2(s)
    int numParameters;
    double probability;
    SCENARIO(int, int);
    SCENARIO(SCENARIO &);
    ~SCENARIO();
private:
};

class SCENARIOS {
public:
    SCENARIO ** scenarios;
    VECTOR * averageSolution1;
    VECTOR ** averageSolution2;
    int numScenarios;
    int numParameters;
    int numVariables1;
    int numVariables2;
    double rho;
    SCENARIOS(char*, int, int);
    ~SCENARIOS();
    void saveAllScenarioSolutionsToFile(int, double, char *);
    void changeRho(double);
    void checkInfeasibility(char *, int);
    void updateAllWeights(double);
    void printAllScenarioSolutions(void);
    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 */

