I'm trying to create a copy of a class instance that I can simulate without affecting the original instance of the class. I've tried using copy.copy
, but I run into this problem:
system.simulate(until=100)
print(system.env.now) # prints 100
copy_of_system = copy.copy(system)
copy_of_system.simulate(until=200)
print(copy_of_system.env.now) # prints 200
print(system.env.now) # prints 200, but should print 100
When I use copy.deepcopy
I get TypeError: can't pickle generator objects
. Is there any effective way to create an independent copy of the system
object?