Esempio n. 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<DHr> hours = new List<DHr>();
            List<String> keys = new List<string>();
            if (DA.GetDataList(0, hours) && DA.GetDataList(1, keys)) {
                if ((hours[0].is_surrogate) && ((hours.Count != 1) && (hours.Count != 12) && (hours.Count != 52) && (hours.Count != 365))) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "This component can only plot unmasked surrogate hours for yearly, monthly, weekly, and daily statistics"); }

                Interval ival_y = new Interval();
                bool calc_ival_y = false;
                if (!(DA.GetData(2, ref ival_y))) {
                    ival_y.T0 = hours[0].val(keys[0]);
                    ival_y.T1 = hours[0].val(keys[0]);
                    calc_ival_y = true;
                }
                Dictionary<string, float[]> val_dict = new Dictionary<string, float[]>();
                List<Interval> val_ranges = new List<Interval>();
                foreach (string key in keys) {
                    Interval ival = new Interval();
                    float[] vals = new float[0];
                    DHr.get_domain(key, hours.ToArray(), ref vals, ref ival);
                    vals = new float[hours.Count];
                    for (int h = 0; h < hours.Count; h++) vals[h] = hours[h].val(key);
                    val_dict.Add(key, vals);
                    val_ranges.Add(ival);
                }

                bool force_start_at_zero = true;

                int stack_dir = StackDirection(val_ranges[0]);
                if (stack_dir==0) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The first key returned nothing but zero values.  I can't deal!");
                foreach (Interval ival in val_ranges) {
                    if (StackDirection(ival) != stack_dir) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "A stacked graph can only handle all negative or all positive numbers.");
                    if (calc_ival_y) {
                        if (stack_dir < 1) {
                            if (ival.T1 > ival_y.T0) ival_y.T0 = ival.T1;
                            if (ival.T0 < ival_y.T1) ival_y.T1 = ival.T0;
                        } else {
                            if (ival.T0 < ival_y.T0) ival_y.T0 = ival.T0;
                            if (ival.T1 > ival_y.T1) ival_y.T1 = ival.T1;
                        }
                    }
                }

                if (force_start_at_zero && calc_ival_y) ival_y.T0 = 0;

                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Interval> intervalTreeOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Interval>();
                intervalTreeOut.Append(new Grasshopper.Kernel.Types.GH_Interval(ival_y),new Grasshopper.Kernel.Data.GH_Path(0));
                foreach (Interval ival in val_ranges) intervalTreeOut.Append(new Grasshopper.Kernel.Types.GH_Interval(ival), new Grasshopper.Kernel.Data.GH_Path(1));

                Plane plane = new Plane(new Point3d(0, 0, 0), new Vector3d(0, 0, 1));
                DA.GetData(3, ref plane);

                Grasshopper.Kernel.Types.UVInterval ival2d = new Grasshopper.Kernel.Types.UVInterval();
                if (!DA.GetData(4, ref ival2d)) {
                    ival2d.U0 = 0.0;
                    ival2d.U1 = 12.0;
                    ival2d.V0 = 0.0;
                    ival2d.V1 = 1.0;
                }

                double barWidth = 1.0;
                DA.GetData(5, ref barWidth);

                Grasshopper.Kernel.Data.GH_Structure<DHr> hourTreeOut = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point> pointTreeOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Point>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Rectangle> rectTreeOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Rectangle>();
                List<Point3d> basepoints = new List<Point3d>();
                for (int h = 0; h < hours.Count; h++) {
                    Point3d gpt = GraphPoint(hours[h].hr, 0.0f, plane, ival_y, ival2d);
                    Point3d wpt = plane.PointAt(gpt.X, 0.0);
                    basepoints.Add(wpt);
                }

                for (int k = 0; k < keys.Count; k++) {
                    Grasshopper.Kernel.Data.GH_Path key_path = new Grasshopper.Kernel.Data.GH_Path(k);
                    List<Point3d> points = new List<Point3d>();
                    List<Rectangle3d> rects = new List<Rectangle3d>();

                    for (int h = 0; h < hours.Count; h++) {
                        float val = val_dict[keys[k]][h];
                        for (int kk = 0; kk < k; kk++) val += val_dict[keys[kk]][h]; // add in all previous values
                        Point3d gpt = GraphPoint(hours[h].hr, val, plane, ival_y, ival2d); // returns a point in graph coordinates

                        hours[h].pos = gpt; // the hour records the point in graph coordinates
                        hourTreeOut.Append(new DHr(hours[h]), key_path);

                        Point3d wpt = plane.PointAt(gpt.X, gpt.Y);
                        points.Add(wpt); // adds this point in world coordinates

                        Interval ival_gx; // interval of horz space occupied by this hour in graphic units
                        Interval ival_gy = new Interval(ival2d.V0, gpt.Y); // interval of vertical space occupied by this hour in graphic units
                        if (!hours[h].is_surrogate) {
                            double delta_x2 = (Math.Abs(ival2d.U.Length) / 8760 / 2.0);
                            ival_gx = new Interval(gpt.X - delta_x2, gpt.X + delta_x2); // interval of horz space occupied by this hour in graphic units
                        } else {

                            // if we've been passed surrogate hours, the spacing between bars may not be consistant
                            // we assume we've been given an hour at the start of the range represented
                            double ival_gx_0 = gpt.X;
                            double ival_gx_1;
                            if (h < hours.Count - 1) {
                                Point3d pt_next = GraphPoint(hours[h + 1].hr, val_dict[keys[k]][h + 1], plane, ival_y, ival2d);
                                ival_gx_1 = gpt.X + (pt_next.X - gpt.X) * barWidth;
                            } else { ival_gx_1 = gpt.X + (ival2d.U1 - gpt.X) * barWidth; }
                            ival_gx = new Interval(ival_gx_0, ival_gx_1);
                            if (hours.Count == 1) ival_gx = ival2d.U;

                        }
                        Rectangle3d rect = new Rectangle3d(plane, ival_gx, ival_gy);
                        rects.Add(rect);
                    }

                    List<Grasshopper.Kernel.Types.GH_Point> gh_points = new List<Grasshopper.Kernel.Types.GH_Point>();
                    foreach (Point3d pt in points) gh_points.Add(new Grasshopper.Kernel.Types.GH_Point(pt));
                    pointTreeOut.AppendRange(gh_points, key_path);

                    List<Grasshopper.Kernel.Types.GH_Rectangle> gh_rects = new List<Grasshopper.Kernel.Types.GH_Rectangle>();
                    foreach (Rectangle3d rec in rects) gh_rects.Add(new Grasshopper.Kernel.Types.GH_Rectangle(rec));
                    rectTreeOut.AppendRange(gh_rects, key_path);

                }

                DA.SetDataTree(0, hourTreeOut);
                DA.SetDataTree(1, intervalTreeOut);
                DA.SetDataTree(2, pointTreeOut);
                DA.SetDataList(3, basepoints);
                DA.SetDataTree(4, rectTreeOut);

            }
        }
Esempio n. 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List<DHr> dhrs = new List<DHr>();
            string period_string = "";
            if ((DA.GetDataList(0, dhrs)) && (DA.GetData(1, ref period_string))) {
                if (period_string == "") { return; }
                period_string = period_string.ToLowerInvariant().Trim();
                this.cycle_type = CType.Invalid;
                if (period_string.Contains("year")) { this.cycle_type = CType.Yearly; } else if (period_string.Contains("monthly diurnal")) { this.cycle_type = CType.MonthlyDiurnal; } else if (period_string.Contains("month")) { this.cycle_type = CType.Monthly; } else if (period_string.Contains("day") || period_string.Contains("daily")) { this.cycle_type = CType.Daily; } else if (period_string.Contains("weekly diurnal")) { this.cycle_type = CType.WeeklyDiurnal; } else if (period_string.Contains("weekly")) { this.cycle_type = CType.Weekly; } else {
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "I don't understand the time period you're looking for.\nPlease choose 'yearly', 'monthly', 'monthly diurnal', 'weekly', 'weekly diurnal', or 'daily'.");
                }

                string[] commonKeys = DHr.commonkeys(dhrs.ToArray());
                Dictionary<string, List<DHr>> stat_hours = new Dictionary<string, List<DHr>>();
                InitStatHours(ref stat_hours);

                HourMask mask = new HourMask();

                switch (this.cycle_type) {

                    case CType.MonthlyDiurnal:
                    case CType.WeeklyDiurnal:
                        Grasshopper.Kernel.Data.GH_Structure<DHr> meanTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                        Grasshopper.Kernel.Data.GH_Structure<DHr> modeTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                        Grasshopper.Kernel.Data.GH_Structure<DHr> highTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                        Grasshopper.Kernel.Data.GH_Structure<DHr> uqTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                        Grasshopper.Kernel.Data.GH_Structure<DHr> medianTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                        Grasshopper.Kernel.Data.GH_Structure<DHr> lqTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                        Grasshopper.Kernel.Data.GH_Structure<DHr> lowTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                        Grasshopper.Kernel.Data.GH_Structure<DHr> sumTree = new Grasshopper.Kernel.Data.GH_Structure<DHr>();

                        switch (this.cycle_type) {
                            case CType.MonthlyDiurnal:
                                for (int mth = 0; mth < 12; mth++) {
                                    InitStatHours(ref stat_hours);
                                    for (int hour = 0; hour < 24; hour++) {
                                        mask.maskByMonthAndHour(mth, hour);
                                        int hh = Util.hourOfYearFromDatetime(Util.baseDatetime().AddMonths(mth).AddHours(hour)) + 1; // had to add one, looks like Util function was designed for parsing non-zero-indexed hours
                                        CalculateStats(dhrs, commonKeys, stat_hours, mask, hh, true);
                                    }
                                    meanTree.AppendRange(stat_hours["meanHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                    modeTree.AppendRange(stat_hours["modeHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                    highTree.AppendRange(stat_hours["highHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                    uqTree.AppendRange(stat_hours["uqHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                    medianTree.AppendRange(stat_hours["medianHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                    lqTree.AppendRange(stat_hours["lqHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                    lowTree.AppendRange(stat_hours["lowHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                    sumTree.AppendRange(stat_hours["sumHrs"], new Grasshopper.Kernel.Data.GH_Path(mth));
                                }
                                break;
                            case CType.WeeklyDiurnal:
                                for (int wk = 0; wk < 52; wk++) {
                                    InitStatHours(ref stat_hours);
                                    for (int hour = 0; hour < 24; hour++) {
                                        mask.maskByWeekAndHour(wk, hour);
                                        int hh = Util.hourOfYearFromDatetime(Util.baseDatetime().AddDays(wk * 7).AddHours(hour)) + 1; // had to add one, looks like Util function was designed for parsing non-zero-indexed hours
                                        CalculateStats(dhrs, commonKeys, stat_hours, mask, hh, true);
                                    }
                                    meanTree.AppendRange(stat_hours["meanHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                    modeTree.AppendRange(stat_hours["modeHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                    highTree.AppendRange(stat_hours["highHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                    uqTree.AppendRange(stat_hours["uqHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                    medianTree.AppendRange(stat_hours["medianHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                    lqTree.AppendRange(stat_hours["lqHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                    lowTree.AppendRange(stat_hours["lowHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                    sumTree.AppendRange(stat_hours["sumHrs"], new Grasshopper.Kernel.Data.GH_Path(wk));
                                }
                                break;
                        }
                        DA.SetDataTree(0, meanTree);
                        DA.SetDataTree(1, modeTree);
                        DA.SetDataTree(2, highTree);
                        DA.SetDataTree(3, uqTree);
                        DA.SetDataTree(4, medianTree);
                        DA.SetDataTree(5, lqTree);
                        DA.SetDataTree(6, lowTree);
                        DA.SetDataTree(7, sumTree);
                        break;

                    case CType.Daily:
                        for (int day = 0; day < 365; day++) {
                            mask.maskByDayOfYear(day, day); // passing in same day twice masks to this single day
                            int hh = Util.hourOfYearFromDatetime(Util.baseDatetime().AddDays(day).AddHours(0)) + 1; // had to add one, looks like Util function was designed for parsing non-zero-indexed hours
                            CalculateStats(dhrs, commonKeys, stat_hours, mask, hh, true);
                        }
                        SetOutputData(DA, stat_hours);
                        break;

                    case CType.Weekly:
                        for (int wk = 0; wk < 52; wk++) {
                            mask.maskByWeek(wk);
                            int hh = Util.hourOfYearFromDatetime(Util.baseDatetime().AddDays(wk * 7).AddHours(0)) + 1; // had to add one, looks like Util function was designed for parsing non-zero-indexed hours
                            CalculateStats(dhrs, commonKeys, stat_hours, mask, hh, true);
                        }
                        SetOutputData(DA, stat_hours);
                        break;

                    case CType.Monthly:
                        for (int mth = 0; mth < 12; mth++) {
                            mask.maskByMonthOfYear(mth);
                            int hh = Util.hourOfYearFromDatetime(Util.baseDatetime().AddMonths(mth).AddHours(0)) + 1; // had to add one, looks like Util function was designed for parsing non-zero-indexed hours
                            CalculateStats(dhrs, commonKeys, stat_hours, mask, hh, true);
                        }
                        SetOutputData(DA, stat_hours);
                        break;

                    case CType.Yearly:
                        mask.fillMask(true); // all hours may pass
                        int hhh = Util.hourOfYearFromDatetime(Util.baseDatetime().AddMonths(6).AddDays(15).AddHours(0)) + 1; // had to add one, looks like Util function was designed for parsing non-zero-indexed hours
                        CalculateStats(dhrs, commonKeys, stat_hours, mask, hhh, true);
                        SetOutputData(DA, stat_hours);
                        break;
                    default:
                        this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Time period option not yet implimented.  Cannot produce statistics.");
                        break;
                }

            }
        }
Esempio n. 3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            AWorld refwrld = new AWorld();
            List<double> v_list = new List<double>();
            //GH_Dict test = GH_Dict.create("a", 1.0);

            //if (!DA.GetData(0, ref refwrld) || !refwrld.IsValid) return;
            //AWorld wrld = new AWorld(refwrld);

            SpatialGraph gph = new SpatialGraph();
            if (!DA.GetData(0, ref gph)) return;

            int nGen = 0;
            string pyString = "";
            if (!DA.GetData(1, ref pyString)) return;
            if (!DA.GetDataList(2, v_list)) return;
            if (!DA.GetData(3, ref nGen)) return;

            // Sets the initial Generation by using the input v_list
            // if it runs out of values, it starts over (wraps)
            double[] val_list = new double[gph.nodes.Count];
            int v_i = 0;
            for (int i = 0; i < gph.nodes.Count; i++)
            {
                if (v_i == v_list.Count) v_i = 0;
                val_list[i] = v_list[v_i];
                v_i++;
            }

            AWorld wrld = new AWorld(gph, val_list);

            _py = PythonScript.Create();
            _py.Output = this.m_py_output.Write;
            _compiled_py = _py.Compile(pyString);

            // console out
            Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_String> consoleOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_String>();

            // Main evaluation cycle
            // Should move code into the Antsworld Class
            for (int g = 0; g < nGen; g++)
            {
                // console out
                this.m_py_output.Reset();

                double[] new_vals = new double[wrld.NodeCount];
                for (int i = 0; i < wrld.NodeCount; i++)
                {
                    int[] neighboring_indices = wrld.gph.NeighboringIndexesOf(i);

                    // build list of neighboring values
                    List<double> neighboring_vals = new List<double>();
                    for (int k = 0; k < neighboring_indices.Length; k++) neighboring_vals.Add(wrld.LatestGen[neighboring_indices[k]]);

                    double d = EvaluateCell(i, wrld.LatestGen[i], neighboring_vals);
                    //double d = g + i + 0.0;

                    new_vals[i] = d;
                }
                wrld.AddGen(new_vals);

                // console out
                Grasshopper.Kernel.Data.GH_Path key_path = new Grasshopper.Kernel.Data.GH_Path(g);
                List<Grasshopper.Kernel.Types.GH_String> gh_strs = new List<Grasshopper.Kernel.Types.GH_String>();
                foreach (String str in this.m_py_output.Result) gh_strs.Add(new Grasshopper.Kernel.Types.GH_String(str));
                consoleOut.AppendRange(gh_strs, key_path);

            }

            DA.SetDataTree(0, consoleOut);
            DA.SetData(1, wrld);
        }
Esempio n. 4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Grasshopper.Kernel.Data.GH_Structure<DHr> hourTreeIn = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
            string key = "";
            int subdivs = 0;
            if ((DA.GetDataTree(0, out hourTreeIn)) && (DA.GetData(1, ref key)) && (DA.GetData(3, ref subdivs)))
            {
                Interval ival_overall = new Interval();
                if (!DA.GetData(2, ref ival_overall)) {
                    // go thru the given hours and find the max and min value for the given key
                    ival_overall.T0 = MDHr.INVALID_VAL;
                    ival_overall.T1 = MDHr.INVALID_VAL;
                    foreach (DHr dhr in hourTreeIn.AllData(true)) {
                        float val = dhr.val(key);
                        if ((ival_overall.T0 == MDHr.INVALID_VAL) || (val < ival_overall.T0)) ival_overall.T0 = val;
                        if ((ival_overall.T1 == MDHr.INVALID_VAL) || (val > ival_overall.T1)) ival_overall.T1 = val;
                    }
                }

                Grasshopper.Kernel.Data.GH_Structure<DHr> hourTreeOut = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Integer> freqTreeOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Integer>();
                Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Interval> ivalTreeOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_Interval>();

                List<Interval> ivalList = new List<Interval>();
                if (ival_overall.IsDecreasing) ival_overall.Swap();
                double delta = ival_overall.Length / subdivs;
                for (int n = 0; n < subdivs; n++) {  ivalList.Add(new Interval(ival_overall.T0 + n * delta, ival_overall.T0 + ((n + 1) * delta)));  }

                for (int b = 0; b < hourTreeIn.Branches.Count; b++)
                {
                    Grasshopper.Kernel.Data.GH_Structure<DHr> hourBranch = new Grasshopper.Kernel.Data.GH_Structure<DHr>();
                    for (int n = 0; n < subdivs; n++) { hourBranch.EnsurePath(n); }
                    List<int> freqOut = new List<int>();

                    List<DHr> hrsIn = hourTreeIn.Branches[b];
                    foreach (DHr dhr in hrsIn)
                    {
                        if (dhr.val(key) < ivalList[0].T0)
                        {
                            hourBranch.Append(dhr, new Grasshopper.Kernel.Data.GH_Path(0));
                            continue;
                        }
                        if (dhr.val(key) > ivalList[ivalList.Count - 1].T1)
                        {
                            hourBranch.Append(dhr, new Grasshopper.Kernel.Data.GH_Path(ivalList.Count - 1));
                            continue;
                        }
                        for (int n = 0; n < subdivs; n++)
                        {
                            if (ivalList[n].IncludesParameter(dhr.val(key)))
                            {
                                hourBranch.Append(dhr,new Grasshopper.Kernel.Data.GH_Path(n));
                                break;
                            }
                        }
                    }

                    for (int bb = 0; bb < hourBranch.Branches.Count; bb++)
                    {
                        Grasshopper.Kernel.Data.GH_Path branch_path = hourTreeIn.Paths[b].AppendElement(bb);
                        hourTreeOut.AppendRange(hourBranch.Branches[bb], branch_path);
                        Grasshopper.Kernel.Types.GH_Integer freq = new Grasshopper.Kernel.Types.GH_Integer(hourBranch.Branches[bb].Count);
                        freqTreeOut.Append(freq, branch_path);
                        Grasshopper.Kernel.Types.GH_Interval ival = new Grasshopper.Kernel.Types.GH_Interval(ivalList[bb]);
                        ivalTreeOut.Append(ival, branch_path);
                    }

                }

                hourTreeOut.Simplify(Grasshopper.Kernel.Data.GH_SimplificationMode.CollapseAllOverlaps);
                freqTreeOut.Simplify(Grasshopper.Kernel.Data.GH_SimplificationMode.CollapseAllOverlaps);
                ivalTreeOut.Simplify(Grasshopper.Kernel.Data.GH_SimplificationMode.CollapseAllOverlaps);

                DA.SetDataTree(0, freqTreeOut);
                DA.SetDataTree(1, ivalTreeOut);
                DA.SetDataTree(2, hourTreeOut);
            }
        }
Esempio n. 5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            AWorld refwrld = new AWorld();
            bool SelectType = false;
            List<double> v_list = new List<double>();
            Random rnd = new Random();

            //if (!DA.GetData(0, ref refwrld) || !refwrld.IsValid) return;
            //AWorld wrld = new AWorld(refwrld);

            SpatialGraph gph = new SpatialGraph();
            if (!DA.GetData(0, ref gph)) return;

            int nGen = 0;
            string pyString = "";
            string spyString = "";
            if (!DA.GetData(1, ref spyString)) return;
            if (!DA.GetData(2, ref SelectType)) return;
            if (!DA.GetData(3, ref pyString)) return;
            if (!DA.GetDataList(4, v_list)) return;
            if (!DA.GetData(5, ref nGen)) return;

            // Sets the initial Generation by using the input v_list
            // if it runs out of values, it starts over (wraps)
            double[] val_list = new double[gph.nodes.Count];
            int v_i = 0;
            for (int i = 0; i < gph.nodes.Count; i++)
            {
                if (v_i == v_list.Count) v_i = 0;
                val_list[i] = v_list[v_i];
                v_i++;
            }

            AWorld wrld = new AWorld(gph, val_list);

            // evaluation function
            _py = PythonScript.Create();
            _py.Output = this.m_py_output.Write;
            _compiled_py = _py.Compile(pyString);

            // selection function
            _spy = PythonScript.Create();
            _py.Output = this.m_py_output.Write;
            _compiled_spy = _py.Compile(spyString);

            // console out
            Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_String> consoleOut = new Grasshopper.Kernel.Data.GH_Structure<Grasshopper.Kernel.Types.GH_String>();

            // Main evaluation cycle
            // Should move code into the Antsworld Class
            for (int g = 0; g < nGen; g++)
            {
                // console out
                this.m_py_output.Reset();
                double[] new_vals = new double[wrld.NodeCount];

                // build list to test
                List<int> nodes_to_test = new List<int>();

                for (int i = 0; i < wrld.NodeCount; i++)
                {
                    // build this now since we will only change a few of them later
                    new_vals[i] = wrld.LatestGen[i];

                    int[] neighboring_indices = wrld.gph.NeighboringIndexesOf(i);
                    double[] n_wts = wrld.gph.NeighboringWeightsOf(i);

                    // build list of neighboring values
                    List<double> neighboring_vals = new List<double>();
                    for (int k = 0; k < neighboring_indices.Length; k++) neighboring_vals.Add(wrld.LatestGen[neighboring_indices[k]]);

                    bool test = SelectCell(i, wrld.LatestGen[i], neighboring_vals, n_wts);

                    if (test) nodes_to_test.Add(i);

                }

                if (SelectType)
                {
                    int trial = rnd.Next(nodes_to_test.Count);
                    int new_index = nodes_to_test[trial];
                    nodes_to_test[0] = new_index;
                    nodes_to_test.RemoveRange(1, nodes_to_test.Count - 1);
                }

                // evaluate list of cells
                for (int j = 0; j < nodes_to_test.Count; j++)
                {
                    int i = nodes_to_test[j];
                    int[] neighboring_indices = wrld.gph.NeighboringIndexesOf(i);

                    // build list of neighboring values
                    List<double> neighboring_vals = new List<double>();
                    for (int k = 0; k < neighboring_indices.Length; k++) neighboring_vals.Add(wrld.LatestGen[neighboring_indices[k]]);

                    double d = EvaluateCell(i, wrld.LatestGen[i], neighboring_vals, wrld.gph.NeighboringWeightsOf(i));
                    //double d = g + i + 0.0;

                    new_vals[i] = d;
                }
                wrld.AddGen(new_vals);

                // console out
                Grasshopper.Kernel.Data.GH_Path key_path = new Grasshopper.Kernel.Data.GH_Path(g);
                List<Grasshopper.Kernel.Types.GH_String> gh_strs = new List<Grasshopper.Kernel.Types.GH_String>();
                foreach (String str in this.m_py_output.Result) gh_strs.Add(new Grasshopper.Kernel.Types.GH_String(str));
                consoleOut.AppendRange(gh_strs, key_path);

            }

            DA.SetDataTree(0, consoleOut);
            DA.SetData(1, wrld);
        }