Exemple #1
0
    def setUp(self):

        # Platform (win32, win64, linux32, linix64)
        platform = get_sys_arch()
        assert platform, 'Unsupported platform type!'

        # Temp directory
        self.tmpdir = tempfile.mkdtemp()

        # Parent directory
        parent = os.path.dirname(__file__)

        # Resources
        self.fmu_path = os.path.join(parent, 'resources', 'simple2R1C',
                                     'Simple2R1C_{}.fmu'.format(platform))
        inp_path = os.path.join(parent, 'resources', 'simple2R1C',
                                'inputs.csv')
        ideal_path = os.path.join(parent, 'resources', 'simple2R1C',
                                  'result.csv')
        est_path = os.path.join(parent, 'resources', 'simple2R1C', 'est.json')
        known_path = os.path.join(parent, 'resources', 'simple2R1C',
                                  'known.json')

        self.inp = pd.read_csv(inp_path).set_index('time')
        self.ideal = pd.read_csv(ideal_path).set_index('time')

        with open(est_path) as f:
            self.est = json.load(f)
        with open(known_path) as f:
            self.known = json.load(f)

        # PS settings
        self.max_iter = 3
        self.try_lim = 2
    def setUp(self):

        # Platform (win32, win64, linux32, linux64)
        platform = get_sys_arch()
        assert platform, "Unsupported platform type!"

        # Temp directory
        self.tmpdir = tempfile.mkdtemp()

        # Parent directory
        parent = os.path.dirname(__file__)

        # Resources
        self.fmu_path = os.path.join(parent, "resources", "simple2R1C",
                                     "Simple2R1C_{}.fmu".format(platform))
        inp_path = os.path.join(parent, "resources", "simple2R1C",
                                "inputs.csv")
        ideal_path = os.path.join(parent, "resources", "simple2R1C",
                                  "result.csv")
        est_path = os.path.join(parent, "resources", "simple2R1C", "est.json")
        known_path = os.path.join(parent, "resources", "simple2R1C",
                                  "known.json")

        # Assert there is an FMU for this platform
        assert os.path.exists(
            self.fmu_path
        ), "FMU for this platform ({}) doesn't exist.\n".format(
            platform) + "No such file: {}".format(self.fmu_path)

        self.inp = pd.read_csv(inp_path).set_index("time")
        self.ideal = pd.read_csv(ideal_path).set_index("time")

        with open(est_path) as f:
            self.est = json.load(f)
        with open(known_path) as f:
            self.known = json.load(f)

        # MODESTGA settings
        self.gen = 2
        self.pop = None  # Set individually
        self.trm = None  # Set individually
        self.workers = None  # Set individually
Exemple #3
0
    def setUp(self):

        # Platform (win32, win64, linux32, linux64)
        platform = get_sys_arch()
        assert platform, 'Unsupported platform type!'

        # Temp directory
        self.tmpdir = tempfile.mkdtemp()

        # Parent directory
        parent = os.path.dirname(__file__)

        # Resources
        self.fmu_path = os.path.join(parent, 'resources', 'simple2R1C',
                                     'Simple2R1C_{}.fmu'.format(platform))
        inp_path = os.path.join(parent, 'resources', 'simple2R1C',
                                'inputs.csv')
        ideal_path = os.path.join(parent, 'resources', 'simple2R1C',
                                  'result.csv')
        est_path = os.path.join(parent, 'resources', 'simple2R1C', 'est.json')
        known_path = os.path.join(parent, 'resources', 'simple2R1C',
                                  'known.json')

        # Assert there is an FMU for this platform
        assert os.path.exists(self.fmu_path), \
            "FMU for this platform ({}) doesn't exist.\n".format(platform) + \
            "No such file: {}".format(self.fmu_path)

        self.inp = pd.read_csv(inp_path).set_index('time')
        self.ideal = pd.read_csv(ideal_path).set_index('time')

        with open(est_path) as f:
            self.est = json.load(f)
        with open(known_path) as f:
            self.known = json.load(f)

        # GA settings
        self.gen = 4
        self.pop = 8
        self.trm = 3
Exemple #4
0
    def setUp(self):

        # Platform (win32, win64, linux32, linix64)
        platform = get_sys_arch()
        assert platform, "Unsupported platform type!"

        # Temp directory
        self.tmpdir = tempfile.mkdtemp()

        # Parent directory
        parent = os.path.dirname(__file__)

        # Resources
        self.fmu_path = os.path.join(parent, "resources", "simple2R1C",
                                     "Simple2R1C_{}.fmu".format(platform))
        inp_path = os.path.join(parent, "resources", "simple2R1C",
                                "inputs.csv")
        ideal_path = os.path.join(parent, "resources", "simple2R1C",
                                  "result.csv")
        est_path = os.path.join(parent, "resources", "simple2R1C", "est.json")
        known_path = os.path.join(parent, "resources", "simple2R1C",
                                  "known.json")

        # Assert there is an FMU for this platform
        assert os.path.exists(
            self.fmu_path
        ), "FMU for this platform ({}) doesn't exist.\n".format(
            platform) + "No such file: {}".format(self.fmu_path)

        self.inp = pd.read_csv(inp_path).set_index("time")
        self.ideal = pd.read_csv(ideal_path).set_index("time")

        with open(est_path) as f:
            self.est = json.load(f)
        with open(known_path) as f:
            known_dict = json.load(f)
            known_records = dict()
            for k, v in known_dict.items():
                known_records[k] = [v]
            self.known_df = pd.DataFrame.from_dict(known_records)
Exemple #5
0
import json
import os
import pandas as pd
from modestpy.utilities.sysarch import get_sys_arch
from modestpy.estim.scipy.scipy import SCIPY
import matplotlib.pyplot as plt

if __name__ == "__main__":
    """
    This file is supposed to be run from the root directory.
    Otherwise the paths have to be corrected.
    """

    # DATA PREPARATION ==============================================
    # Resources
    platform = get_sys_arch()
    assert platform, 'Unsupported platform type!'
    fmu_file = 'Simple2R1C_ic_' + platform + '.fmu'

    fmu_path = os.path.join('examples', 'simple', 'resources', fmu_file)
    inp_path = os.path.join('examples', 'simple', 'resources', 'inputs.csv')
    ideal_path = os.path.join('examples', 'simple', 'resources', 'result.csv')
    est_path = os.path.join('examples', 'simple', 'resources',
                            'est_validate_hj.json')
    known_path = os.path.join('examples', 'simple', 'resources',
                              'known_validate_hj.json')

    # Working directory
    workdir = os.path.join('examples', 'simple', 'workdir')
    if not os.path.exists(workdir):
        os.mkdir(workdir)