setting an attribute in a create action
setting an attribute in a create action
I'm having trouble setting the attribute in a create action, with which I'd appreciate help. The attribute new value is:
if(newVendorFix●VendorNum<1) {"Vendor1"} else if (newVendorFix●VendorNum<2){"Vendor2"} else {"Vendor3"}
VendorNum is a randomly assigned value:
RandomUniform(0,model.vendor population size-1)
The idea is that a list of (built-in data) vendors is used to pick a random vendor associated with a VendorFix.
This works when I don't include the elseif in the above expression. That is, no problems when the attribute new value is:
if(newVendorFix●VendorNum<1) {"Vendor1"} else {"Vendor3"}
With the elseif expression here is the error message that I get:
Generated code at (2883,2) }expected (context: Createntity by key (uint); COLLECTIONOF_collection_of_vendorfix_by_mpcvd_identity", in collection_of_vendorfix_by mpcvd_identity
It seems to be complaining about the creating of the collection of VendorFix. The fact that it works for the plain if-then-else, but not when the else if is added in seems strange. Is this a known limitation or error?
Any help is appreciated.
Thanks,
Andy
if(newVendorFix●VendorNum<1) {"Vendor1"} else if (newVendorFix●VendorNum<2){"Vendor2"} else {"Vendor3"}
VendorNum is a randomly assigned value:
RandomUniform(0,model.vendor population size-1)
The idea is that a list of (built-in data) vendors is used to pick a random vendor associated with a VendorFix.
This works when I don't include the elseif in the above expression. That is, no problems when the attribute new value is:
if(newVendorFix●VendorNum<1) {"Vendor1"} else {"Vendor3"}
With the elseif expression here is the error message that I get:
Generated code at (2883,2) }expected (context: Createntity by key (uint); COLLECTIONOF_collection_of_vendorfix_by_mpcvd_identity", in collection_of_vendorfix_by mpcvd_identity
It seems to be complaining about the creating of the collection of VendorFix. The fact that it works for the plain if-then-else, but not when the else if is added in seems strange. Is this a known limitation or error?
Any help is appreciated.
Thanks,
Andy
Re: setting an attribute in a create action
I think this may be a glitch in the if-then-else code for attributes. I'm investigating & will report back ASAP.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
Here's a workaround, using a Process List action. It's a little more complex to set up, but generally it's a lot better because
(a) there's no possibility of errors (a Buyer getting a reference to a Vendor that doesn't exist)
(b) you can change the size of the Vendor list just by changing the initialization data.
(a) there's no possibility of errors (a Buyer getting a reference to a Vendor that doesn't exist)
(b) you can change the size of the Vendor list just by changing the initialization data.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
Thanks Tom! This is a very nice solution that allows easier extension to a larger numbers of vendor agents. Should be very useful for selecting random elements of a collection. I've got your approach working in my application already.
Re: setting an attribute in a create action
Cool. We need one more piece to make this more efficient, which is a way to select an entity without having to run a Process List over the whole collection. That's coming.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
Tom,
I have noticed one problem with my execution of the above fix. I am not pulling the data for vendors and buyers from a table as you are. I am generating them dynamically. For instance I generate 10 vendors as an action, and assigning an attribute to each vendor (whether it is a "player" or "nonplayer"). This allows generating subcollections of vendors showing aggregate values for players and nonplayers separately. This all works, but in the graphs of those aggregate values, a null run (for vendor_0001) shows up in addition to the aggregate values for the players and nonplayers. Is there a way to get rid of this null run. It does not provide an entry in the entity picker to deselect it. Thanks!
I have noticed one problem with my execution of the above fix. I am not pulling the data for vendors and buyers from a table as you are. I am generating them dynamically. For instance I generate 10 vendors as an action, and assigning an attribute to each vendor (whether it is a "player" or "nonplayer"). This allows generating subcollections of vendors showing aggregate values for players and nonplayers separately. This all works, but in the graphs of those aggregate values, a null run (for vendor_0001) shows up in addition to the aggregate values for the players and nonplayers. Is there a way to get rid of this null run. It does not provide an entry in the entity picker to deselect it. Thanks!
Re: setting an attribute in a create action
Can you post the model, or mail it to us at info at ventity dot biz?
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
I sent the model to info@ventity.biz. I'll try to summarize the resolution, if any to this forum. Thanks!
Re: setting an attribute in a create action
I think the problem is that you're using "No Data" which creates one entity of each type, with default settings. That would explain the presence of an extra one (though I'm not sure which one is surplus in your model).
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
You are quite right. I thought you had to use no data if you did not use any data from tables. Good lesson that there is a difference between no data and using a table with no data. That fixed my problem. Thank you!
Re: setting an attribute in a create action
Great! We'll have to clarify that in the Help system.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
I'm having a problem with using if-then-else statements in actions when assigning the new value for an attribute. Ventity is giving me an error. I used the model that Tom sent in this thread previously to illustrate this problem - in the pickVendor action. Just setting the vendorID using an if then else creates the error. Am I doing something wrong here, is this a known bug, or is there a workaround to this. I can't seem to figure out a workaround on my own that works.
Re: setting an attribute in a create action
The error is definitely caused by the if statement in the attribute initialization, which is currently unsupported. You have:
if (true) {refVendor●VendorID} else {refVendor●VendorID}
The true and false clauses both set the same value - what would you like it to do if the if statement worked? I think I have a workaround.
if (true) {refVendor●VendorID} else {refVendor●VendorID}
The true and false clauses both set the same value - what would you like it to do if the if statement worked? I think I have a workaround.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
Ok - thanks. I’ll send the full model to Ventity.biz for a possible workaround. I’ll report out any findings in this forum. Sorry I can’t post the full model to this public forum - just a policy of my employing organization.
Re: setting an attribute in a create action
No problem.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: setting an attribute in a create action
Tom pointed out that Ventity 2.0 (partially) resolves the issue with the if then elseif statements in setting an attribute in a create action. You just need to use the IFTHENELSE() construct instead of the if () {} else {}. Thanks for the fix!