# Path: lems/base/base.py
# class LEMSBase(object):
#     """
#     Base object for PyLEMS.
#     """
# 
#     def copy(self):
#         return copy.deepcopy(self)
# 
#     def toxml(self):
#         return ""
# 
# Path: lems/base/stack.py
# class Stack(LEMSBase):
#     """
#     Basic stack implementation.
#     """
# 
#     def __init__(self):
#         """
#         Constructor.
#         """
# 
#         self.stack = []
#         """ List used to store the stack contents.
#         :type: list """
# 
#     def push(self, val):
#         """
#         Pushed a value onto the stack.
# 
#         :param val: Value to be pushed.
#         :type val: *
#         """
# 
#         self.stack = [val] + self.stack
# 
#     def pop(self):
#         """
#         Pops a value off the top of the stack.
# 
#         :return: Value popped off the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             val = self.stack[0]
#             self.stack = self.stack[1:]
#             return val
#         else:
#             raise StackError("Stack empty")
# 
#     def top(self):
#         """
#         Returns the value off the top of the stack without popping.
# 
#         :return: Value on the top of the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             return self.stack[0]
#         else:
#             raise StackError("Stack empty")
# 
#     def is_empty(self):
#         """
#         Checks if the stack is empty.
# 
#         :return: True if the stack is empty, otherwise False.
#         :rtype: Boolean
#         """
# 
#         return self.stack == []
# 
#     def __str__(self):
#         """
#         Returns a string representation of the stack.
# 
#         @note: This assumes that the stack contents are capable of generating
#         string representations.
#         """
# 
#         if len(self.stack) == 0:
#             s = "[]"
#         else:
#             s = "[" + str(self.stack[0])
#             for i in range(1, len(self.stack)):
#                 s += ", " + str(self.stack[i])
#             s += "]"
#         return s
# 
#     def __repr__(self):
#         return self.__str__()
# 
# Path: lems/base/errors.py
# class SimBuildError(LEMSError):
#     """
#     Exception class to signal errors in building the simulation.
#     """
# 
#     pass
# 
# Path: lems/sim/recording.py
# class Recording(LEMSBase):
#     """
#     Stores details of a variable recording across a single simulation run.
#     """
# 
#     def __init__(self, variable, full_path, data_output, recorder):
#         self.variable = variable
# 
#         self.full_path = full_path
# 
#         self.data_output = data_output
# 
#         self.recorder = recorder
# 
#         self.values = []
# 
#     def __str__(self):
#         return "Recording: {0} ({1}), {2}, size: {3}".format(
#             self.variable, self.full_path, self.recorder, len(self.values)
#         )
# 
#     def __repr__(self):
#         return self.__str__()
# 
#     def add_value(self, time, value):
#         self.values.append((time, value))


from lems.base.base import LEMSBase
from lems.base.stack import Stack
from lems.base.errors import SimBuildError
from lems.sim.recording import Recording
from math import *
import ast
import sys

    def update_shadow_variables(self):
        if self.plastic:
            for var in self.instance_variables:
                self.__dict__[var + "_shadow"] = self.__dict__[var]
            for var in self.derived_variables:
                self.__dict__[var + "_shadow"] = self.__dict__[var]

    def __lt__(self, other):
        return self.id < other.id

    def copy(self):
        """
        Make a copy of this runnable.

        :return: Copy of this runnable.
        :rtype: lems.sim.runnable.Runnable
        """
        if self.debug:
            print("Coping....." + self.id)
        r = Runnable(self.id, self.component, self.parent)
        copies = dict()

        # Copy simulation time parameters
        r.time_step = self.time_step
        r.time_completed = self.time_completed
        r.time_total = self.time_total

        # Plasticity and state stack (?)
        r.plastic = self.plastic

# Path: lems/base/base.py
# class LEMSBase(object):
#     """
#     Base object for PyLEMS.
#     """
# 
#     def copy(self):
#         return copy.deepcopy(self)
# 
#     def toxml(self):
#         return ""
# 
# Path: lems/base/stack.py
# class Stack(LEMSBase):
#     """
#     Basic stack implementation.
#     """
# 
#     def __init__(self):
#         """
#         Constructor.
#         """
# 
#         self.stack = []
#         """ List used to store the stack contents.
#         :type: list """
# 
#     def push(self, val):
#         """
#         Pushed a value onto the stack.
# 
#         :param val: Value to be pushed.
#         :type val: *
#         """
# 
#         self.stack = [val] + self.stack
# 
#     def pop(self):
#         """
#         Pops a value off the top of the stack.
# 
#         :return: Value popped off the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             val = self.stack[0]
#             self.stack = self.stack[1:]
#             return val
#         else:
#             raise StackError("Stack empty")
# 
#     def top(self):
#         """
#         Returns the value off the top of the stack without popping.
# 
#         :return: Value on the top of the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             return self.stack[0]
#         else:
#             raise StackError("Stack empty")
# 
#     def is_empty(self):
#         """
#         Checks if the stack is empty.
# 
#         :return: True if the stack is empty, otherwise False.
#         :rtype: Boolean
#         """
# 
#         return self.stack == []
# 
#     def __str__(self):
#         """
#         Returns a string representation of the stack.
# 
#         @note: This assumes that the stack contents are capable of generating
#         string representations.
#         """
# 
#         if len(self.stack) == 0:
#             s = "[]"
#         else:
#             s = "[" + str(self.stack[0])
#             for i in range(1, len(self.stack)):
#                 s += ", " + str(self.stack[i])
#             s += "]"
#         return s
# 
#     def __repr__(self):
#         return self.__str__()
# 
# Path: lems/base/errors.py
# class SimBuildError(LEMSError):
#     """
#     Exception class to signal errors in building the simulation.
#     """
# 
#     pass
# 
# Path: lems/sim/recording.py
# class Recording(LEMSBase):
#     """
#     Stores details of a variable recording across a single simulation run.
#     """
# 
#     def __init__(self, variable, full_path, data_output, recorder):
#         self.variable = variable
# 
#         self.full_path = full_path
# 
#         self.data_output = data_output
# 
#         self.recorder = recorder
# 
#         self.values = []
# 
#     def __str__(self):
#         return "Recording: {0} ({1}), {2}, size: {3}".format(
#             self.variable, self.full_path, self.recorder, len(self.values)
#         )
# 
#     def __repr__(self):
#         return self.__str__()
# 
#     def add_value(self, time, value):
#         self.values.append((time, value))


# Path: lems/sim/runnable.py
from lems.base.base import LEMSBase
from lems.base.stack import Stack
from lems.base.errors import SimBuildError
from lems.sim.recording import Recording
from math import *
import ast
import sys


    def update_shadow_variables(self):
        if self.plastic:
            for var in self.instance_variables:
                self.__dict__[var + "_shadow"] = self.__dict__[var]
            for var in self.derived_variables:
                self.__dict__[var + "_shadow"] = self.__dict__[var]

    def __lt__(self, other):
        return self.id < other.id

    def copy(self):
        """
        Make a copy of this runnable.

        :return: Copy of this runnable.
        :rtype: lems.sim.runnable.Runnable
        """
        if self.debug:
            print("Coping....." + self.id)
        r = Runnable(self.id, self.component, self.parent)
        copies = dict()

        # Copy simulation time parameters
        r.time_step = self.time_step
        r.time_completed = self.time_completed
        r.time_total = self.time_total

        # Plasticity and state stack (?)
        r.plastic = self.plastic

        r.state_stack = Stack()