class RightAngleTriangle(Modello): """ Use Pythagorus' theorm to model a right angled triangle. >>> T = RightAngleTriangle("T", a=3, b=4) >>> T.c 5 >>> T = RightAngleTriangle("T", b=4, c=5) >>> T.a 3 """ a = InstanceDummy("a", real=True, positive=True) b = InstanceDummy("b", real=True, positive=True) c = sqrt(a**2 + b**2)
class SingleDataEntryFlow(ScalableFlow): """Flow model for single data entry. >>> sde = SingleDataEntryFlow("SDE", scale=10, entry_time=7) >>> sde.output 520/1533 """ entry_time = InstanceDummy("entry_time", positive=True, rational=True) unit_output = Rational(8 * 260, 24 * 365) / entry_time
class DoubleDataEntryFlow(ScalableFlow): """Flow model for double data entry. Currently has assumptions like the cost per data entry member is equal regardless of serving entry and resolution queues. >>> dde = DoubleDataEntryFlow("DDE") >>> dde.unit_output 26/(219*_DDE_entry_time) """ entry_time = InstanceDummy("entry_time", positive=True, rational=True) conflict_rate = InstanceDummy("resolution_rate", positive=True, rational=True) resolution_time = InstanceDummy("resolution_time", positive=True, rational=True) disagreement_rate = InstanceDummy("disagreement_rate", positive=True, rational=True) unit_output = Rational(8 * 260, 24 * 365) / entry_time / 2
class ScalableFlow(Modello): """ Something that has input and output, which can be scaled and has associated costs. Input and output are assumed to be something like frequency (Hz) >>> sde = ScalableFlow("flow", fulfilment=2, scale=1, unit_output=1) >>> sde.fulfilment, sde.scale, sde.unit_output (2, 1, 1) >>> sde.input, sde.output (1/2, 1) >>> sde.unit_cost, sde.cost (_flow_unit_cost, _flow_unit_cost) """ # latency calculations could also be included input = InstanceDummy("input", positive=True, rational=True) unit_output = InstanceDummy("unit_output", positive=True, rational=True) unit_cost = InstanceDummy("unit_cost", positive=True, rational=True) scale = InstanceDummy("scale", positive=True, rational=True) cost = unit_cost * ceiling(scale) output = unit_output * scale fulfilment = output / input utilization = output / (ceiling(scale) * unit_output)
class Job(Modello): """ Simple model of a job in the UK. This assumes all the values are yearly. >>> job = Job("job", salary=32000, hours=253*8, expenses=0) >>> job.hourly_income.evalf(4) 12.50 >>> job.employer_expense.evalf(7) 35225.34 """ salary = InstanceDummy("salery", rational=True, positive=True) hours = InstanceDummy("hours", rational=True, positive=True) expenses = InstanceDummy("expenses") income = ( salary - IncomeTaxFunction(salary) - NationalInsuranceFunction(salary) - expenses ) hourly_income = income / hours employer_expense = salary + EmployerNationalInsuranceFunction(salary)
class ExampleClass(Modello): thing = InstanceDummy("thing")
class ExampleB(Modello): conflicted = InstanceDummy("conflicted") b = conflicted