Salabim

Latest version: v24.0.9

Safety actively analyzes 642283 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 19 of 25

2.2.4

=========================
Automatic naming of components, queues, etc. results in shorter names now.
E.g., instead of 'client............11' the name is now 'client.11'.
Also the name is not shortened anymore (was: 20 characters).

The methods Monitor.print_statistics(), MonitorTimestamp.print_statistics(),
Queue.print_statistics, State.print_statistics and Resource.print_statistics()
have an improved layout.

The method Monitor.print_histogram() and MonitorTimestamp.print_histogram()
have an improved layout.

Monitor and MonitorTimestamp names are now serialized.

Please have a look at the much improved manual.

2.2.3

=========================
PIL 4.2.1 (shipped with the latest WinPython distribution), has a bug when
trying to animate text with the null string.
Therefore, salabim now has special code to handle null strings correctly.

Minor bug with importing PIL under Pythonista fixed.

2.2.2

=========================
Component.wait() now allows to check for":
- a value
yield self.wait((light,'red'))
- an expresssion to be evaluated. the value has to be $ which is replaced by
str(state.value()), each time the condition is checked
yield self.wait((light,'$in ("red","yellow")'))
yield self.wait((level,'<30'))
it is possible to use state for the state under test and self for the
component under test
- a function to be called each time the condition is checked.
the function is called with one argument, being
a tuple of state.value(), component, state
yield self.wait((light,lambda x: x[0] in ('red,ýellow'))
yield self.wait((level,lambda x: x[0]<30))


Component.activate() has an additional parameter keep_wait, which controls whether
waits are to be kept upon an activate, thus allowing an update of a timeout.

When salabim detects that PIL or tkinter is not installed when trying to animate,
the error message now provided instructions on how to install the relevant package.

When salabim detects that cv2 is not installed when trying to produce a video,
the error message now provided instructions on how to install the relevant package.

2.2.1

=========================
Bug in Component.request() corrected.
This prevented Machine shop animated to work properly.

2.2.0

=========================
Introduced a new process control method: wait.
This functionality is similar but not equal to the waitevent and queueevent
methods in SimPy2.
The method allows a process to wait for a any if all of (number of) certain
value(s) of a so called state.
A state has a value and each time this value change, all components waiting for
this state are checked.
The class State has a number of methods, which allow to control the state:
set(value) sets the value. Normally used without argument, in which
case True will be used.
reset() resets the value to False=
trigger(value) sets the value (default True), triggers any components waiting,
and then immediately resets to a given value (default False).
optionally, the number of components to be honored with the trigger
value may be limited (if used, most like 1).
The current value of a state can be retrieved with
get() or by directly calling the state.
So, e.g. dooropen.get() or dooropen()
On top of that, the queue of waiters may be accessed with
State.waiters()
And there is a monitor to register the the value over time, called State.value .
.
The waiters queue and value will be monitored by default.

Components can wait for a certain value of a state (or states) by
yield self.wait(dooropen)
or
yield self.wait((dooropen,False))
And for several states at one time:
yield self.wait(frontdooropen,backdooropen) to test for fontdooropen OR backdooropen
or
yield self.wait(dooropen,lighton,all=True) to test for dooropen AND lighton
It is also possible to check for several values of one state:
yield self.wait((light,'green'),(light,'yellow')) tests for lighth is green of yellow

The method wait can have an optional timeout parameter.
If they are timed out, Component.fail() is True.

If a component is in a wait state, the status waiting will be returned.
In order to test for this state, use either
c.state() == waiting
or
c.iswaiting()
See the example script demo wait.py for a demonstration of the trigger and time out functionality.

Deprecated functionality:
In method Component.request(), it is no longer allowed to specify
greedy behaviour. Also strict_order is not anymore supported.
The reason for this is its limited use and stability.

Technical note: The process of honouring requests is now optimized by keeping track of
the minimal requested quantity for each resource.

Method request_failed() changed to failed().
This method now also refers to fails of wait.

For Monitor and MonitorTimestamp, the tallied values are now converted to a numeric
equivalent, if not yet int/float. Values of type bool are converted to 0 for False and
1 for True (as usual).
For all other types a conversion to int/float is tried. If that's not possible,
0 is used.
So after
m=sim.Monitor(name='m')
m.tally(2)
m.tally(True)
m.tally('12')
m.tally('red')
m.x() is array([2,1,12,0])
This automatic conversion is used in all monitor methods, apart from getting the
current value.
So, after the above code,
m() will return 'red'
The unprocessed values are available in the lists
Monitor._x
end
MonitorTimestamp._x (along with the coresponding MonitorTimestamp._t)
So, after the above code m._x is (2,True,'12','red') .

The __repr__ methods of Environment, Queue, Component, Monitor, Resource and the
distributions, now return
Environment(name), Queue(name), ...
E.g. now
q=sim.Queue('visitors')
print(q)
returns
Queue(visitors)
Getting information about one of the above class instances is now provided by
the method print_info (formerly available via __repr__).
E.g.
q=sim.Queue('visitors')
print(q)
prints something like
Queue 0x26e8e78ada0
name=visitors
no components

The default random stream when initializing Environment is now 1234567. If a
purely, not reproducable, stream by by specifying Environment(random_seed=None)
or sim.random_seed(None).
If you don't want any action when calling Environment (thats usually for
subsequent run) (cf. Elevator animated.py specify the null string, so
Environment(random_seed='')
All sample models have been updated to reflect this change, i.e. no more
random_seed=1234567 in the call to Environment, there.

Convention change:
Instead of naming the default environment de, from now env is prefered.
All sample models have been updated accordingly.

Documentation change only:
Package numpy is required.
The order of components in Queue.union() and Queue.intersect() is now specified.

Packaging remarks:
Release notes.txt is now called changelog.txt, to be more in line with PyPI standards.

salabim is now on PyPI. So now you can install salabim also with pip install salabim!

2.1.3

=========================
Upto now it was a requirement to build an __init__ method with a call
to super().__init__ if the component had to be initialized in some way.
This is a rather awkward construction and difficult to grasp for beginners.
Although this construction is still accepted, there is now a more elegant
method: setup.
If this method is present in the definition of a component, it will be called
after salabim has done all its initialization and even after the activate
statement, if applicable.
The method may have arguments. If so, whencreating the component, it is
required to use keyword arguments.

salabim any version salabim>=2.1.3
--------------------------------------------------------------------
class Car(sim.Component): class Car(sim.Component):
def __init__(self,name,color): def setup(self,color):
super().__init__(name=name) self.color=color
self.color=color Car(name='BMW',color='red')
Car(name='BMW',color=red)

Note that the __init__ construction is still available.

All examples that used the __init__ construction have been updated
accordingly.

Both salabim and all examples now conform to PEP8 (with the exception
of requirements on line length and visual indent).

Bug in print_statistics when monitoring was False fixed.

Page 19 of 25

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.