Naming objects

anas
2012-11-07
2013-03-16
  • anas
    anas
    2012-11-07

    Hi,

    Is there a way to dynamically name a large number of objects in a glm file instead of doing that one by one?
    For example, in the file named "4_6_IEEE_14-bus_and_37-Node_Integration.glm" (which is an example provided in one of the courses) there are 629 houses and I want to name them in a more structured way like house0001, house0002 and so on. Doing this by hand one by one is not practical.

    Anas

     
  • Which version are you using?

     
  • anas
    anas
    2012-11-07

    I am using:
    GridLAB-D 3.0.0.3316 Hassayampa

     
  • Sorry, I forgot the trailing semicolon:

    object house:..5 { 
      name `MyHouse_{id}`;
    }
    
     
  • Take a look at https://sourceforge.net/apps/mediawiki/gridlab-d/index.php?title=SEQ and let me know whether this would meet your need.  I haven't posted the code yet and won't be able to until Friday because I have to run tests on my desktop machine rather my laptop (which is all I've got right now).  Since it hasn't been posted yet, feel free to recommend changes to the spec on the wiki talk page associated with this page.

     
  • anas
    anas
    2012-11-08

    What exactly I am looking for is something like this: 50 triplex_meters, each meter is parent to one house and each house is parent to one zipload. I need to name them {meter0, house0, zipload0} {meter1, house1, zipload1} and so on… I am using the server mode to access gridlabd from another application so I need a systematic way to refer to objects.
    I tried this (but did not work as the id's are give in sequence for any object created):

    object triplex_meter:..5 {
        name `meter_{id}`;
        nominal_voltage 120;
        object house {
            name `house_{id}`;
            object ZIPload: {
                name `zipload_{id}`;
            };
        };
    }
    

    As you mentioned I am looking for a "custom sequence number".  I think the SEQ and INC would suffice in case they can be used inside the object for naming. Can we execute those commands inside the object?
    If yes, then I can replace the id with SEQ_A and increment it.
    I can write a script using another language that creates the glm file but it will be relatively big and hard coded, I am keeping this as a last resort.

    Thanks a lot
    Anas

     
  • Frank Tuffner
    Frank Tuffner
    2012-11-08

    Hello Anas,
      To interject another thought in here, we've done items similar to what you've described, but we've always done them with some form of external scripting language.  Under the PopulationScript folder of the repository (http://gridlab-d.svn.sourceforge.net/viewvc/gridlab-d/Taxonomy_Feeders/PopulationScript/) there are some MATLAB files we used to generate files for our Smart Grid Investment Grant evaluation project, many with consistent numbering.  This could easily be adapted to python, pearl, or some other scripting language.  dchassin has recently implemented some functionality (I don't know if it is fully implemented/tested yet) that allows external commands to be called as part of the GLM sequence, so that may be a way to implement this.
     
    I'm not sure if it is any further help, but I wanted to point out how we've done similar things for our work.

    -Frank

     
  • Ok.  I will work a fix into trunk in the next few days.  I have it working on my laptop, but I can't test it on Windows for a couple of days and I don't want to post it until I can.  If you want it now I can email you a copy of my globals.c in which the patch is to be made.

     
  • Frank Tuffner
    Frank Tuffner
    2012-11-08

    The code has been tested under the Windows build and committed to the repository as part of revision 3590.  If you encounter any problems with it, please post a reply back here.

    -Frank

     
  • Thanks Frank!

     
  • anas
    anas
    2012-11-08

    First, I am using Ubuntu 10.04 (not sure if that makes any difference but you mentioned Windows above)
    I would like to try it, if I got that right I guess you were talking about SEQ/INC, is that right?
    Should I use the version currently in the trunk? 

    Thanks
    Anas

     
  • Frank Tuffner
    Frank Tuffner
    2012-11-08

    Hello again Anas,
      Sorry, the Windows discussions above were to make sure the change didn't break different platforms (I believe Dave was testing it on a Mac).  The above changes have been Incorporated into the current subversion of trunk.  If you download and build it, it will have the SEQ/INC functionality and sounds like it may do what you were trying to accomplish in the first message.
     
      -Frank

     
  • anas
    anas
    2012-11-08

    Sounds great!
    So this means I should be doing something like this:

    #SEQ_A=${SEQ_A:INIT}
    object triplex_meter:..5 {
        name `meter_${SEQ_A:INC}`;
        nominal_voltage 120;
        object house {
            name `house_${SEQ_A}`;
            object ZIPload: {
                name `zipload_${SEQ_A}`;
            };
        };
    }
    

    Anas

     
  • Frank Tuffner
    Frank Tuffner
    2012-11-08

    Your syntax looks mostly correct, based on how things were described.  From my simple experiment, it appears you need to change your first line to something like

    #print ${SEQ_A:INIT}
    

    or similar (the macro parser wants a known command after the #, so it silently fails with the code you had posted).  Unfortunately, once that works, it appears to still fail saying there are too many "meter_1" objects (which means it basically isn't working as expected).  We'll look into this further and post here once it is fixed (unless the above change works for, in which case please let us know).

    -Frank

     
  • You have to be careful to use expansion variable syntax when embedding things in multi-object definitions, e.g.,

    global int32 SEQ_A 0;
    object house:..10 {
      name `House_{SEQ_A:INC}`;
    }
    

    Note the absence of the $ before the {SEQ_A:INC}.  This delays interpretation of the global variable name until the name is actually parsed rather than when the line is loaded from the file.  Due to my forgetfulness, this didn't work until changeset 3592.

     
  • Your question led me to do finish I've been meaning to do for a long time, which is full parameter expansion in the style of bash.  The {SEQ_name:op} syntax is still supported, but the syntax described in http://sourceforge.net/apps/mediawiki/gridlab-d/index.php?title=Parameter_expansion is much more comprehensive in that it not only supports incrementing, but it supports assignment, substitution, increment/decrement, and boolean/trinary operations on global variables.  This feature was committed in changeset 3595.

    Note that there appears to be a problem with using the global directive to create the , which has been reported in ticket 628. It seems that sometimes directives are not processed before the next macro is processed.  As a result, a directive to declare an int32 global variable is not processed before the next macro attempts to use it, resulting in an error.

     
  • anas
    anas
    2012-11-12

    I am trying to install the current trunk verion to try the things you descriped but I am getting error after executing "sudo make install":
    .
    .
    .
    libtool: install: /usr/bin/install -c gridlabd.bin /usr/lib/gridlabd /gridlabd.bin
    /usr/bin/install: target `/gridlabd.bin' is not a directory
    make: ***  Error 1
    make: Leaving directory `/home/anas/gridlab-d/core'
    make: ***  Error 2
    make: Leaving directory `/home/anas/gridlab-d/core'
    make: ***  Error 1
    make: Leaving directory `/home/anas/gridlab-d/core'
    make: ***  Error 2
    make: Leaving directory `/home/anas/gridlab-d/core'
    make: ***  Error 1

    Currently I am using an older version.

    Anas

     
  • Nathan Tenney
    Nathan Tenney
    2012-11-13

    Anas,

    Can you give me some more information?  What operating system are you compiling on?

     
  • Nathan Tenney
    Nathan Tenney
    2012-11-13

    Nevermind, I just saw that you are building with Ubuntu 10.04.  I don't have a vm yet with that version, so I'll create one and test the build and install on that version.  It's possible that changes we made to support newer versions of the autotools we broke things for this version of Ubuntu.

     
  • Sara Ghaemi
    Sara Ghaemi
    2012-12-17

    Hi,

    I was trying to include more than one house in one node in IEEE-4 node system.
    shall I define id some where!??

    thanks

    object triplex_meter {
           name tm_A1;
           phases AS;
           nominal_voltage 120;
    }

    object house :..5 {
         parent tm_A1;
         name `house_{id}`;
    //name house_A1;
         floor_area 80 m^2;
         //schedule_skew 2754;
         heating_system_type HEAT_PUMP;
         heating_COP 4.00;
         cooling_system_type HEAT_PUMP;
    thermostat_cycle_time 3600;
        object recorder {
    file `setpoints_{id}.csv`;
    limit 100000;
    interval 300;
    property heating_setpoint,cooling_setpoint, air_temperature, outdoor_temperature;
    };

         object controller {
               //schedule_skew 2754;
               market Market_1;
               bid_mode OFF;
               control_mode DOUBLE_RAMP;
               resolve_mode SLIDING;
               //resolve_mode DEADBAND;
               slider_setting_heat 2.5;
               slider_setting_cool 2.5;
               heating_base_setpoint 68;
               cooling_base_setpoint 74;
               period 300;
               average_target current_price_mean_24h;
               standard_deviation_target current_price_stdev_24h;
               target air_temperature;
               heating_setpoint heating_setpoint;
               //heating_setpoint ;
               heating_demand last_heating_load;
               cooling_setpoint cooling_setpoint;
               cooling_demand last_cooling_load;
               deadband thermostat_deadband;
               total hvac_load;
               load hvac_load;
               state power_state;
           };

     
  • Jason Fuller
    Jason Fuller
    2012-12-17

    No, 'id' is an internal variable assigned to each object.

    There appears to be an extra space between your declaration of house and the colon - I'm not positive, but this will probably cause syntax issues.

     
  • anas
    anas
    2012-12-17

    Hi, I am a gridlabd user. As the above responses from PNNL guys indicate this is how you define "id" (I have tried this and it works):

    #print ${SEQ_A:INIT};    //SEQ_A is for "id" here and this is where you define it.
    object triplex_meter:..5 {
    name `meter{SEQ_A:INC}`;
            object house {
    name `house{SEQ_A}`;
    };
    }

    Anas