コード例 #1
0
        internal static Dictionary <string, object> FindPreferredProgs(List <string> progIdList, List <string> progAdjList)
        {
            List <string> progAdjId = new List <string>();

            for (int i = 0; i < progIdList.Count; i++)
            {
                string        adjacency = progAdjList[i];
                List <string> adjList   = adjacency.Split('.').ToList();
                progAdjId.AddRange(adjList);
            }
            List <int> numIdList = new List <int>();

            for (int i = 0; i < progAdjId.Count; i++)
            {
                int value = 0;
                try { value = Int32.Parse(progAdjId[i]); }
                catch { value = (int)BasicUtility.RandomBetweenNumbers(new Random(i), progAdjId.Count - 1, 0); }
                numIdList.Add(value);
                progAdjId[i] = value.ToString();
            }
            List <double> adjWeightList = new List <double>();

            for (int i = 0; i < progIdList.Count; i++)
            {
                int count = 0;
                for (int j = 0; j < progAdjId.Count; j++)
                {
                    if (i == numIdList[j])
                    {
                        count += 1;
                    }
                }
                adjWeightList.Add(count);
            }

            adjWeightList = BasicUtility.NormalizeList(adjWeightList, 0, 10);
            return(new Dictionary <string, object>
            {
                { "ProgIdList", (progIdList) },
                { "ProgAdjList", (progAdjList) },
                { "ProgAdjWeightList", (adjWeightList) }
            });
        }
コード例 #2
0
        //compute glare  values
        public static List <List <double> > ComputeGlareValues(List <Point3d> floorPoints, List <Point3d> furniturePoints,
                                                               List <Point3d> lightPoints, double threshDist = 10, double lightSize = 3, double numSpecialLights = 2, double recompute = 1)
        {
            int           pos      = 0;
            List <double> posList  = new List <double>();
            List <double> distList = new List <double>();
            List <double> ugrList  = new List <double>();
            int           count    = 0;
            double        numD     = BasicUtility.RandomBetweenNumbers(new Random(), 0.1, 0.35);

            for (int i = 0; i < numSpecialLights; i++)
            {
                posList.Add(lightPoints.Count * (i + 1) * numD);
            }

            pos = (int)(lightPoints.Count * 0.20);
            for (int i = 0; i < floorPoints.Count; i++)
            {
                List <Point3d> selectedPts = new List <Point3d>();
                Point2d        pt2FloorPt  = ConvertToPoint2d(floorPoints[i]);
                for (int j = 0; j < furniturePoints.Count; j++)
                {
                    Point2d pt2Furniture = ConvertToPoint2d(furniturePoints[j]);
                    double  distance     = PointUtility.DistanceBetweenPoints(pt2Furniture, pt2FloorPt);
                    distList.Add(distance);
                    if (distance < threshDist)
                    {
                        selectedPts.Add(furniturePoints[j]);
                    }
                }// end of j for loop
                if (selectedPts.Count > 0)
                {
                    lightPoints.AddRange(selectedPts);
                }
                double ugrValue = CalculateUGR(lightPoints, floorPoints[i], posList, lightSize, recompute);
                ugrList.Add(ugrValue);
                count += 1;
            }
            List <double> val2 = new List <double>(), val3 = new List <double>();

            for (int n = 0; n < ugrList.Count; n++)
            {
                val2.Add(0); val3.Add(0);
            }
            List <double>         ugrListNormalized = BasicUtility.NormalizeList(ugrList, 0, 255);
            List <List <double> > result            = new List <List <double> >();

            result.Add(ugrListNormalized);
            result.Add(val2);
            result.Add(val3);
            result.Add(distList);
            result.Add(new List <double> {
                count
            });
            result.Add(ugrList);
            result.Add(new List <double> {
                lightSize
            });
            result.Add(posList);
            return(result);
        }
コード例 #3
0
        internal static Dictionary <string, object> FindPreferredProgs(double circulationFactor = 1, int caseStudy = 0, string programDocumentPath = "", bool stackingOptionsProg = false)
        {
            double                dim = 5;
            StreamReader          reader;
            List <string>         progIdList       = new List <string>();
            List <string>         programList      = new List <string>();
            List <string>         deptNameList     = new List <string>();
            List <string>         progQuantList    = new List <string>();
            List <string>         areaEachProgList = new List <string>();
            List <string>         prefValProgList  = new List <string>();
            List <string>         progAdjList      = new List <string>();
            List <string>         progTypeList     = new List <string>();
            List <List <string> > dataStack        = new List <List <string> >();
            List <ProgramData>    programDataStack = new List <ProgramData>();
            Stream                res;

            if (programDocumentPath == "")
            {
                //string[] csvText = Properties.Resources.PROGRAMCSV.Split('\n');
                if (caseStudy == 1)
                {
                    res = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SpacePlanning.src.Asset.MayoProgram_1.csv");
                }
                else if (caseStudy == 2)
                {
                    res = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SpacePlanning.src.Asset.OtherProgram.csv");
                }
                else if (caseStudy == 3)
                {
                    res = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SpacePlanning.src.Asset.ProgramDocument_Reg.csv");
                }
                else if (caseStudy == 4)
                {
                    res = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SpacePlanning.src.Asset.OtherProgram.csv");
                }
                else if (caseStudy == 5)
                {
                    res = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SpacePlanning.src.Asset.MULTIDEPT.csv");
                }
                else
                {
                    res = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SpacePlanning.src.Asset.ProgramDocument.csv");
                }

                reader = new StreamReader(res);
            }
            else
            {
                reader = new StreamReader(File.OpenRead(@programDocumentPath));
            }
            int readCount = 0;


            //StreamReader reader = new StreamReader(res);
            string docInfo = reader.ReadToEnd();

            string[] csvText = docInfo.Split('\n');
            //Trace.WriteLine(csvText);
            foreach (string s in csvText)
            {
                if (s.Length == 0)
                {
                    continue;
                }
                var values = s.Split(',');
                if (readCount == 0)
                {
                    readCount += 1; continue;
                }
                progIdList.Add(values[0]);
                programList.Add(values[1]);
                deptNameList.Add(values[2]);
                progQuantList.Add(values[3]);
                prefValProgList.Add(values[6]);
                progTypeList.Add(values[7]);
                progAdjList.Add(values[8]);
                List <Cell> dummyCell = new List <Cell> {
                    new Cell(Point2d.ByCoordinates(0, 0), 0, 0, 0, true)
                };

                ProgramData progData = new ProgramData(Convert.ToInt32(values[0]), values[1], values[2], Convert.ToInt32(Convert.ToDouble(values[3])),
                                                       Convert.ToDouble(values[4]), Convert.ToInt32(values[6]), progAdjList, dummyCell, dim, dim, values[7], stackingOptionsProg); // prev multipled circulationfactor with unit area of prog
                programDataStack.Add(progData);
            }// end of for each statement

            List <string> progAdjId = new List <string>();

            for (int i = 0; i < progIdList.Count; i++)
            {
                string        adjacency = progAdjList[i];
                List <string> adjList   = adjacency.Split('.').ToList();
                progAdjId.AddRange(adjList);
            }
            List <string> strList   = new List <string>();
            List <int>    numIdList = new List <int>();

            for (int i = 0; i < progAdjId.Count; i++)
            {
                strList.Add(progAdjId[i]);
                int value = 0;
                try { value = Int32.Parse(progAdjId[i]); }
                catch { value = (int)BasicUtility.RandomBetweenNumbers(new Random(i), progAdjId.Count - 1, 0); }
                numIdList.Add(value);
                progAdjId[i] = value.ToString();
            }
            List <double> adjWeightList = new List <double>();

            for (int i = 0; i < progIdList.Count; i++)
            {
                int count = 0;
                for (int j = 0; j < progAdjId.Count; j++)
                {
                    if (i == numIdList[j])
                    {
                        count += 1;
                    }
                }
                adjWeightList.Add(count);
            }

            adjWeightList = BasicUtility.NormalizeList(adjWeightList, 0, 10);
            string x = "";

            return(new Dictionary <string, object>
            {
                { "ProgIdList", (progIdList) },
                { "ProgramList", (programList) },
                { "DeptNameList", (deptNameList) },
                { "ProgQuantList", (progQuantList) },
                { "AreaEachProgList", (areaEachProgList) },
                { "ProgPrefValList", (prefValProgList) },
                { "ProgAdjList", (progAdjList) },
                { "ProgAdjWeightList", (adjWeightList) }
            });
        }