Simulate the assembly of parts in Arena Simulation Software - events

I am simulating an assembly process in Arena. To keep things simple, suppose a model that assigns bags to passengers.
Each entity has a different ID (Entity.SerialNumber): I would like to check which bag has been assigned to which passenger.
How could I write a log file saving the ID of passenger and ID of the assigned bag?

First you must declare an attribute for the original entity that I understand that in this case would be the passenger, for example: ID = ID + 1, then with the separate module you duplicate the original entity, now both entities can have their independent flow and when you want to put them together again you can do it with a batch module using the rule: by attribute or with a match module using the type: based on attribute.

Related

Possible to set file name for h2o.save_model() (rather then simply use the model_id value)?

Trying to save an h2o model with some specific name that differs from the model's model_id field, but trying something like...
h2o.save_model(model=model,
path='/some/path/then/filename',
force=False)
just creates a dir/file structure like
some
|__path
|__then
|__filename
|__<model_id>
as opposed to
some
|__path
|__then
|__filename
Is this possible to do from the save_model method?
I can't / hesitate to simply change the model_id before calling the save method because the model names have timestamps appended to them to avoid name collisions with other models that may be on the h2o cluster (am trying to remove these timestamps when saving on disk and simplifying the name on the cluster before saving creates a time where naming collision can occur if other processes are also attempting to save such a model (of, say, a different timestamp)).
Any way to get this behavior or other common alternatives / workarounds?
This is currently not possible, however I created a feature request here. There is a related question here which shows a solution for R (could be adapted to Python). The work-around is just to rename the file manually using a few lines of R/Python code.

Suggestion with basic drools syntax

The following is a basic drools syntax:
$customer : Customer( )
Account( ) from $customer.accounts
As far as I know the first line create a new variable and assign it to the fact.
However I can't quite understand the second line especially what the "Account()" part means...
You have written class Customer, or must know it to understand what's going on here. Presumably it contains a Collection<Account> accounts (see note), which is (by the engine) retrieved one by one so that the rule fires for each Account object contained in Customer's object.
The rule will fire once for each Account object stored in any of the collections contained in all the Customer facts in working memory, with $customer being bound to the containing Customer.
You can bind another variable to Account.
Note: It could also contain a field Account accounts, but I hope the name was chosen carefully.

Hadoop Cascading : CascadeException "no loops allowed in cascade" when cogroup pipes twice

I'm trying to write a Casacading(v1.2) casade (http://docs.cascading.org/cascading/1.2/userguide/htmlsingle/#N20844) consisting of two flows:
1) The first flow outputs urls to a db table, (in which they are automatically assigned id's via an auto-incrementing id value).
This flow also outputs pairs of urls into a SequenceFile with field names "urlTo", "urlFrom".
2) The second flow reads from both these sources and tries to do a CoGroup on "urlTo" (from the SequenceFile) and "url" (from the db source) to get the db record "id" for each "urlTo".
It then does a CoGroup on "urlFrom" and "url" to get the db record "id" for each "urlFrom".
The two flows work individually - if I call flow.complete() on the first before running the second flow. But if I put the two flows in a cascade object I get the error
cascading.cascade.CascadeException: no loops allowed in cascade, flow: urlLink*url*url, source: JDBCTap{connectionUrl='jdbc:mysql://localhost:3306/mydb', driverClassName='com.mysql.jdbc.Driver', tableDesc=TableDesc{tableName='urls', columnNames=null, columnDefs=null, primaryKeys=null}}, sink: JDBCTap{connectionUrl='jdbc:mysql://localhost:3306/mydb', driverClassName='com.mysql.jdbc.Driver', tableDesc=TableDesc{tableName='url_link', columnNames=[urlLinkFrom, urlLinkTo], columnDefs=[bigint(20), bigint(20)], primaryKeys=[urlLinkFrom, urlLinkTo]}}
on trying to configure the cascade.
I can see it's coming from the addEdgeFor function of the CascadeConnector but I'm not clear on how to resolve this problem.
I've never used Cascade / CascadeConnector before. Is there something I'm missing?
It seems like your some paths for source and sinks are the same.
A Cascade uses the concept of Direct Graphs to build the Cascade itself so if you have a flow source and a sink source pointing to the same location that in essence creates a loop and is disallowed in the concept of Directed Graphs since
it does not go from:
Source Location A to Sink Location B
but instead goes from:
Source Location A to Sink Location A.
"A Tap is not given an explicit name by design. This is so a given Tap instance can be re-used in different {#link Flow}s that may expect a source or sink by a different logical name, but are the same physical resource."
"In general, two instances of the same Tap class must have differing Identifiers (and different #equals)."
It turns out that JDBCTaps generate their identifier from the connection url alone (and do not include the table name). So as I was reading from one table and writing to a different table in the same database it seemed like I was reading from and writing to the same Tap and causing a loop.
As a work-around, I'm going to subclass the JDBCTap and override the getIdentifier() method to include the table name.

With boost::msm eUML, if I give attributes_ << to the state machine or state, how do I (re)set them?

If I add attributes to an event, I know I can then use the event name like a function...
BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(*someEvent*, *someAttributeList*)
someStateMachine.process_event(
someEvent (
valueOfSomeAttribute1, // sets the attribute value here
valueOfSomeAttribute2))
and that inside an action I can this back by writing
evt.get_attribute(someAttribute1); // retrieve the attribute value
Now, if I set an attribute for an entire machine, like so:
BOOST_MSM_EUML_DECLARE_STATE_MACHINE((transition_table,
init_ << initState,
Entry_Action,
Exit_Action,
attributes_ << someAttribute1 << someAttribute2,
configure_<< someConfigurationStuff ),
newStateMachineType)
How do I go about setting a value for someAttribute1?
Same question for states:
BOOST_MSM_EUML_STATE(
(someEntryAction,
someExitAction,
attributes_ << someAttribute1,
configure_<< someConfigurationStuff)
,newStateName)
How do I go about setting a value for someAttribute1?
Finally,
Is there a way to change the attributes after the object is created?
For instance, I'd like to have an attribute for the state machine, and in one of my states, remember some piece of information that I can store in the state machine. (In this case, I want to store a socket.)
Thanks.
How do I go about setting a value for someAttribute1?
You can:
change the reference you just got (get_attribute returns a reference): ++evt.get_attribute(someAttribute1).
use the functors to write the attribute in your table directly. For example, following action is possible: /++fsm_(someAttribute1)
For states, you can do the same. And for state machines, well, ditto.
Again, you can either use the Fsm template parameter in your actions, or the functors (fsm_, event_, etc.)
You can find good example of all in the examples or tests (for example test/CompositeEuml.cpp or test/AnonymousEuml.cpp).
HTH,
Christophe

Model for localizable attribute values in Core Data Entity?

If I want to create a entity in Core Data that has attributes with values that should be localizable I'm wondering how the most efficient way would look like?
As a example let's assume the following structure:
Book
name (localizable)
description (localizable)
author
An localized book entry would look like this:
name: "A great novel" (en/international),
"Ein großartiger Roman" (de),
"Un grand roman" (fr)
description:
"Great!" (en/international),
"Großartig!" (de),
"Grand!" (fr)
author: "John Smith"
In a SQL/SQLite implementation I would use two tables. A books table containing the book information (author, the english/international name and description) and the localizationBooks table that is related using the primary key of the corresponding book. This second table contains the localized name and description values as well as the languageCode. This would allow to have a scalable number of localizations.
For fetching the data I would use a
SELECT COALESCE(localizationBooks.name, books.name)
to get the actual values for the given language code. This allows to use the international english value as fallback for unsupported languages.
Would this require a separate entity in Core Data (e.g. BookLocalization) that has a relation to the Book or is there another recommended way of doing this?
The strategy you mention is usually the best. As you suggest, this requires an extra entity for the localized properties.
You can then write a helper method on your Books entity to get the appropriate localization object for a given language and use it like this:
[book bookLocalizationForLanguage:#"de"].name
You could even take it a step further and just add properties like localizedName, localizedDescription on the Books entity which will fetch the appropriate localized value.
Well, despite that this topic is 3 years old... I just stumbled upon it, asking my self the very same as the original poster. I found another thread with an answer.
I'll just repeat it in here in case somebody else hits this thread (Answer from Gordon Hughes):
Good practices for multiple language data in Core Data
To summarize:
Let's say you have Entity Books. Then you will have to make an additional one, called Localizedbook for example. In Books you have the attribute "title" and in LocalizedBook you have "localizedTitle" and "locale" for international strings like "en_US".
You now have to set the relationship between title -> localizedTitle (one to many, as one original title can have multiple translations).
So, every time you fetch "title" you will get the "localizedTitle" given to a specific locale, if the relations are set correctly.

Resources