Exemplo n.º 1
0
        public static List<object[]> Run(GH_Component component, IList<object> data, System.Collections.IDictionary kwargs)
        {
            Type t = component.GetType();
              var method = t.GetMethod("SolveInstance", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

              List<object[]> input = BuildInputList(data);

              int output_count = component.Params.Output.Count;
              int iterations = input.Count;
              List<object[]> output = new List<object[]>(output_count);
              for (int i = 0; i < output_count; i++)
            output.Add(new object[iterations]);

              bool run_parallel = false;
              if (kwargs != null && kwargs.Contains("multithreaded"))
            run_parallel = (bool)kwargs["multithreaded"];

              if (run_parallel)
              {
            System.Threading.Tasks.Parallel.For(0, input.Count, (iteration) => SolveIteration(iteration, component, input, output, method));
              }
              else
              {
            for( int iteration=0; iteration<input.Count; iteration++)
            {
              SolveIteration(iteration, component, input, output, method);
            };
              }
              return output;
        }
Exemplo n.º 2
0
        /*******************************************/

        public static INode ToNode(this GH_Component component)
        {
            switch (component.GetType().FullName)
            {
            case "MathComponents.FunctionComponents.Component_Series":
                MethodNode node = PopulateNode(new MethodNode {
                    Method = typeof(BH.Engine.Data.Compute).GetMethod("Series")
                }, component);
                node.Inputs = new List <ReceiverParam> {
                    node.Inputs[2], node.Inputs[0], node.Inputs[1]
                };
                return(node);

            default:
                return(null);
            }
        }
Exemplo n.º 3
0
        public static List <object[]> Run(GH_Component component, IList <object> data, System.Collections.IDictionary kwargs)
        {
            Type t      = component.GetType();
            var  method = t.GetMethod("SolveInstance", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            List <object[]> input = BuildInputList(data);

            int             output_count = component.Params.Output.Count;
            int             iterations   = input.Count;
            List <object[]> output       = new List <object[]>(output_count);

            for (int i = 0; i < output_count; i++)
            {
                output.Add(new object[iterations]);
            }

            bool run_parallel = false;

            if (kwargs != null && kwargs.Contains("multithreaded"))
            {
                run_parallel = (bool)kwargs["multithreaded"];
            }

            if (run_parallel)
            {
                System.Threading.Tasks.Parallel.For(0, input.Count, (iteration) => SolveIteration(iteration, component, input, output, method));
            }
            else
            {
                for (int iteration = 0; iteration < input.Count; iteration++)
                {
                    SolveIteration(iteration, component, input, output, method);
                }
                ;
            }
            return(output);
        }