# Path: ndlib/models/compartments/enums/SAType.py
# class SAType(Enum):
#     MEAN = 0
#     VARIANCE = 1
#     MIN = 2
#     MAX = 3


from SALib.sample import saltelli
from SALib.analyze import sobol
from ndlib.models.compartments.enums.SAType import SAType
import numpy as np
# TODO
# - Parallel execution
# - Add sensitivity analysis options



class ContinuousModelRunner(object):
    def __init__(self, ContinuousModel, config, node_status=True):
        self.model = ContinuousModel
        self.config = config
        self.node_status = node_status

    def run(self, N, iterations_list,  initial_statuses, constants_list=None):
        results = []

        n_iterations = len(iterations_list)
        n_initial_statuses = len(initial_statuses)

        if constants_list:
            n_constants = len(constants_list)

        for i in range(N):
            print('\nRunning simulation ' + str(i + 1) + '/' + str(N) + '\n')
            if constants_list:
                self.model.constants = constants_list[i % n_constants]
            self.model.set_initial_status(initial_statuses[i % n_initial_statuses], self.config)
            output = self.model.iteration_bunch(iterations_list[i % n_iterations], node_status=self.node_status)
            results.append(output)


# Path: ndlib/models/compartments/enums/SAType.py
# class SAType(Enum):
#     MEAN = 0
#     VARIANCE = 1
#     MIN = 2
#     MAX = 3


# Path: ndlib/models/ContinuousModelRunner.py
from SALib.sample import saltelli
from SALib.analyze import sobol
from ndlib.models.compartments.enums.SAType import SAType
import numpy as np

# TODO
# - Parallel execution
# - Add sensitivity analysis options



class ContinuousModelRunner(object):
    def __init__(self, ContinuousModel, config, node_status=True):
        self.model = ContinuousModel
        self.config = config
        self.node_status = node_status

    def run(self, N, iterations_list,  initial_statuses, constants_list=None):
        results = []

        n_iterations = len(iterations_list)
        n_initial_statuses = len(initial_statuses)

        if constants_list:
            n_constants = len(constants_list)

        for i in range(N):
            print('\nRunning simulation ' + str(i + 1) + '/' + str(N) + '\n')
            if constants_list:
                self.model.constants = constants_list[i % n_constants]
            self.model.set_initial_status(initial_statuses[i % n_initial_statuses], self.config)
            output = self.model.iteration_bunch(iterations_list[i % n_iterations], node_status=self.node_status)
            results.append(output)


        return results