Results 1 to 6 of 6
  1. #1
    kestlerhawk is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Automatic creation of variables based on matrix data

    Hello All,

    i'm interested in ACE simulation and using java to do so.

    based on the research i'm doing, i have to create 1000+ agents that are all similar in build with only their internal variable values different.

    so this is easy enough until there are a few hundred variables to create, initialize, and cross check.

    what i'm interested in doing is automating this process as follows:

    instead of, for example, using the following code to create a bounded normal distribution across all the agents:

    final Normal visionNormal = RandomHelper.createNormal( AgentConstants.AGENT_VISION_MEAN, AgentConstants.AGENT_VISION_SD);

    int vision = 0;
    while (vision > 5.0 || vision < 0) {

    vision = visionNormal.nextInt();

    }

    agent.setVision(vision);


    i would like to make an automatic function that would take this matrix entry:

    i.e. matrix entry:



    [ int (variable type) vision (variable name) normal (distribution type) 0 (min) 5 (max) etc... ]



    would be used to create the above code parametrically.

    the trick i'm facing is how to convert the string int and double values in the entry into code to produce the required variable in the class.

    So how do i corollate matrix[0][0] as the variable type, matrix[0][1] into the variable name, etc... and then be able to access the variable as would be possible if i used the initial set of code i provided.

    kind regards, and thank you for your support in advance,

    Soli

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: Automatic creation of variables based on matrix data

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    kestlerhawk is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Re: Automatic creation of variables based on matrix data

    Hey Darryl,

    Thanks for the guide, i'll get more acquainted with it.

    Cheers,

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,979
    Rep Power
    5

    Default Re: Automatic creation of variables based on matrix data

    Java is a compiled language. As soon as your code starts to run, it is already compiled to a binary format. So there simply are no variables to create anymore, its all set in stone.

    In stead of variables, consider using a collection class, for example a HashMap. Then you can bind values to a certain key, the key can represent your 'variable'.

  5. #5
    kestlerhawk is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Re: Automatic creation of variables based on matrix data

    Hello Gimabl2,

    i think i understand your point. basically, once a class is created, and compiled, i can make infinite instances of that class with different values for the variables in the class, but i cannot create new variables within the class, or for that matter at all...

    i think that makes perfect sens, but in the case of building the class in the first place, that is what i'm more interested in.

    that sounds very ambiguous so i will make it more clear:

    i'm using the Repast Java libraries. and in them we create contexts, and within the contests, i will create say 100 agents..

    for these 100 agents, each will have say 40 variables that will each have a normal distribution across all teh agents, and interact according to equations to determine the agent's behaviour during the run of the model, once compiled.

    so for each of these variables, i would have to create a distribution, and poll that distribution to get a variable value for each of the agents, and then verify that each value is within acceptable limits.

    but say that during the run of the model, one agent needs to access a specific number of variable (randomly) from another agent. well, it would have to poll itself with a list of all it's variables, and decide to poll teh agent base don what it can find in iteself (since both agents are of the same class...)

    so the question becomes can i say make an array of all the variables that each agent has, ie

    variables = {sight, height, eyeColor, walkingLimit, etc...}

    and use that for the polling, and if so, can i use an expanded version of that matrix to actually initialize all the variables at the beginning run of the model. so basically, once all is compiled, and i have to actually put values to the variables in the class.

    i think it is harder for me to explain than it really is.

    sorry for the trouble,

    Soli

  6. #6
    rawalc is offline Member
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Default Re: Automatic creation of variables based on matrix data

    I typically create JAR components from MATLAB for matrix operations. Being an engineer, it allows me to work on the math with only a basic knowledge in Java. To bring you in perspective this is what I am talking about. What suggestions do you have on this kind of approach?

Similar Threads

  1. Object creation at runtime based on kind of input
    By mapred.learn in forum Advanced Java
    Replies: 1
    Last Post: 03-10-2011, 05:33 AM
  2. Matrix Data Assignment
    By sehudson in forum New To Java
    Replies: 5
    Last Post: 03-01-2011, 07:45 AM
  3. Matrix Data Type
    By fraB3422 in forum New To Java
    Replies: 7
    Last Post: 02-27-2011, 02:08 AM
  4. Replies: 5
    Last Post: 07-09-2010, 06:14 AM
  5. Replies: 0
    Last Post: 08-28-2008, 05:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •