Error: Generated code at (1245, 31)

A place for Ventity software questions & answers
Post Reply
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Error: Generated code at (1245, 31)

Post by Jack Harich »

In starting out on a new Ventity model, I've encountered an error that looks like a bug. The model is attached.

The error is:
Generated code at (1245, 31) 'voter' does not contain a definition for 'one_ODCV' and no accessible extension method 'one_ODCV' accepting a first argument of type 'voter' could be found (are you missing a using directive or an assembly reference?) (context: executing StoreVariablesyAndResetBuffers(); aggregate "Sum one", in collec-tion_of_voter_by_politician_supported)
I appreciate the helpful "(are you missing a using directive or an assembly reference?)" but I don't know what that means. It could be for the programmer.

Here's when the error occurred, so that you might be able to replicate the error. I created a collection of Voter partitioned on politician supported. Now I need the count of voters for each politician. On the Voter[politician supported] diagram, I dragged and dropped an aggregate, and then edited it. I changed Aggregation Function to Sum and Target Variable to one. The one auxiliary equals 1. I did this because there is no Aggregation Function for Count. Then I ran the model and the error occurred.

Testing, I see that if I change Aggregation Function to None there is no error, only a warning: 'Aggregate "Aggregate1" Chosen aggregate function is "None"; the value will always be 0.' Thus the error is provoked by setting Aggregation Function to Sum.

Is there perhaps a better way to count the entities in each partition in a partitioned collection?

Thanks. This is a showstopper, though I've not yet explored how I can get past it.
Attachments
RDem 02 Has error voter does not contain def for.zip
(12.8 KiB) Downloaded 361 times
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Re: Error: Generated code at (1245, 31)

Post by Jack Harich »

My my. Today I copied the model with the error, opened it, ran it, and no error occurred.

So for now, this problem is solved. I will also try to use the built in Count, since it sure looks like it could count the groups in the partitioned collection. Thanks!
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Re: Error: Generated code at (1245, 31)

Post by Jack Harich »

More on this. The Voter[politician supported] inspector has a built-in Count variable. Dragging and dropping it on any diagram EXCEPT Voter[politician supported] gives this immediate error:
'Reference "Voter by politician supported" Missing condition for "politician supported" attribute'
There is no error if Count is dropped on the Voter[politician supported] diagram.

This sure makes it hard to use the Count on other diagrams. If I try to use my own calculation of count, the same problems arise. Thus, I find it impossible to count the partitions in a partitioned collection.

The model is attached, in the error state. Ventity version 4.9beta. On the Country entity diagram, Count from Inspector Voter[politician supported] has been dropped on the diagram. This immediately causes the error. Thanks!
Attachments
RDem 05 Has error attached to post.zip
(12.97 KiB) Downloaded 318 times
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Re: Error: Generated code at (1245, 31)

Post by Jack Harich »

More on this. I worked very hard, studying doc and videos. In Exercise 4, I was able to drop a count on a non collection entity diagram. So it's possible. Examining my model, I discovered that after you drop the count on the diagram and provoke the error, you can right click on the variable. The menu has Edit Auxiliary and Edit Reference. Editing the reference allows entering the missing Value to Match. The error disappears. At last. BTW, I changed from Ventity 4.9beta to 4.8.

The problem is this cannot be done with the inspector, which is where I was trying over and over to fix the problem. Right click there and I never get to edit the missing Value to Match. I'm very new to Ventity, but this sure looks like a severe usability problem. Thanks again.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Error: Generated code at (1245, 31)

Post by tomfid »

Glad you found the builtin count.

Generated code errors come from the compiler. Usually they reflect an actual error in the model that we haven't managed to write a friendly message for. We consider that a bug so the report is helpful.

The reference error from dropping count into another entity is intentional. You need to define the reference. You can either right-click the referenced variable on the diagram, or just double-click the error to get there.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Error: Generated code at (1245, 31)

Post by tomfid »

You can edit the reference in the inspector, but you have to be in the right place. The reference will appear on the References tab of the inspector for the target entity where the variable is used.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Error: Generated code at (1245, 31)

Post by tomfid »

In the model you posted above, the undefined "voter by politician" reference is in the Country. It's not clear how to define that, since the country doesn't know about any particular politician. You could hard code it to a particular value ("Bob", or something in an attribute).

It would be more typical for that reference to live in the Voter (so they could decide if they're backing a winner) or the Politician (so they know how many voters they have). Both of those have an attribute identifying a politician.
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Re: Error: Generated code at (1245, 31)

Post by Jack Harich »

Hi Tom, thanks for all the comments. The model is so new I haven't fleshed in countries have politicians and voters, etc. I'm still wet behind the ears on all this, since Ventity is a superstar, superset of Vensim. :-) !
You can edit the reference in the inspector, but you have to be in the right place. The reference will appear on the References tab of the inspector for the target entity where the variable is used.
I see. Thanks!
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Error: Generated code at (1245, 31)

Post by tomfid »

There's a significant change of mindset required that we haven't quite figured out how to teach. Relational database users seem to pick it up fastest. You'll get there.
Post Reply