question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generalising class names

See original GitHub issue

When defining classes of individuals in the system, their names must be of the form "Class <i>" where i is an integer. For example:

>>> import ciw
>>> N = ciw.create_network(
...     arrival_distributions={
...         "child": [ciw.dists.Exponential(0.2)],
...         "adult": [ciw.dists.Exponential(0.3)],
...     },
...     service_distributions={
...         "child": [ciw.dists.Exponential(0.3)],
...         "adult": [ciw.dists.Exponential(0.3)],
...     },
...     number_of_servers=[5],
... )
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-93-0eddbdb2b06e> in <module>
      8         "adult": [ciw.dists.Exponential(0.3)],
      9     },
---> 10     number_of_servers=[5],
     11 )

~/anaconda3/lib/python3.7/site-packages/ciw/import_params.py in create_network(arrival_distributions, baulking_functions, class_change_matrices, number_of_servers, priority_classes, queue_capacities, service_distributions, routing, batching_distributions)
     68         params['batching_distributions'] = batching_distributions
     69 
---> 70     return create_network_from_dictionary(params)
     71 
     72 

~/anaconda3/lib/python3.7/site-packages/ciw/import_params.py in create_network_from_dictionary(params_input)
    109     """
    110     params = fill_out_dictionary(params_input)
--> 111     validify_dictionary(params)
    112     # Then make the Network object
    113     arrivals = [params['arrival_distributions']['Class ' + str(clss)]

~/anaconda3/lib/python3.7/site-packages/ciw/import_params.py in validify_dictionary(params)
    266             set(['Class ' + str(i) for i in range(params['number_of_classes'])]))
    267     if not consistant_class_names:
--> 268         raise ValueError('Ensure correct names for customer classes.')
    269     if all(isinstance(f, types.FunctionType) for f in params['routing']):
    270         num_nodes_count = [

ValueError: Ensure correct names for customer classes.

Is this a necessary condition for ciw to function as it stands? If not, I don’t see why the class names can’t be recorded when the network is created and then placed when a record is created.

It isn’t a major problem except when you have a number of external classes that you’d like to extract from ciw.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
daffidwildecommented, Dec 12, 2019

it could be possible to do this in such a way where you could pass lists without it actually needing special consideration.

That would be jolly nice to have both. I suspect that my suggestion would be implemented in a very similar way.

1reaction
geraintpalmercommented, Dec 12, 2019

Internally, if the names are just being treated like indices then I imagine the dictionary could be iterated over in another way so ciw is completely class name invariant.

Yes I like this. Shouldn’t be too many changes - and would still be back compatible 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generalization, Specialization, and Inheritance - SourceMaking
Generalization is the process of extracting shared characteristics from two or more classes, and combining them into a generalized superclass. Shared ...
Read more >
Generalization relationships in UML models and diagrams - IBM
Generalization relationships are used in class, component, deployment, and use-case diagrams to indicate ... Generalization relationships do not have names.
Read more >
Generalization
There are several small problems: employees have positions (e.g. "manager", "programmer", "CEO", etc.) which should always be appended to the name. Also, ...
Read more >
Java - Generalize different classes, similar methods (without ...
Java - Generalize different classes, similar methods (without changing the subclasses?) ; class AnotherGivenServiceConsumer ; public ...
Read more >
Generalization and Specialization in Java - GeeksforGeeks
Example 1: Relatively General Class: Money Relatively Specific Class: Dollar, Euro, Rupees. Example 2: Lemon, Orange are more Specific than ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found