public void UpdatePosition() { markerRef.GetPosition(out longitude, out latitude); mx = longitude; my = latitude; OnlineMapsUtils.LatLongToMercat(ref mx, ref my); Cluster p = parent; while (p != null) { int tx, ty; GetTilePosition(p.zoom, out tx, out ty); if (p.CompareTiles(p.zoom, tx, ty)) { parent.RemoveChild(this); p.Add(this); break; } if (p.parent != null) { p = p.parent; } else { parent.RemoveChild(this); p.Add(this); break; } } }
/// <summary> /// This function reads through the dsm vDsmt identifies the identical rows (these are sccs ) and pass back this information(in an object array format) to the calling function /// </summary> /// <param name="DSM"></param> /// <returns></returns> private static List <Cluster> GatherClusters(DesignStructureMatrix DSM) { //gathers the clusters var clusterPresent = new List <int>(); var clusters = new List <Cluster>(DSM.RowCount); for (int c = 0; c < DSM.ColumnCount; c++) { var clusterlist = new Cluster(); if (!clusterPresent.Contains(c)) { clusterPresent.Add(c); clusterlist.Add(c); for (int r = 0; r < DSM.RowCount; r++) { if (c == r) { continue; } if (DSM.Row(c).Equals(DSM.Row(r))) { clusterlist.Add(r); clusterPresent.Add(r); } } clusters.Add(clusterlist); clusterlist = null; } } return(clusters); }
public Cluster Generate() { Cluster cluster = new Cluster(); for (Int32 i = -M; i <= M; ++i) { for (Int32 j = -M; j <= M; ++j) { for (Int32 k = -M; k <= M; ++k) { var atoms = lattice.GetAtoms(i, j, k); foreach (var atom in atoms) { Vector3 dist = new Vector3(atom.Position.X, atom.Position.Y, 0); if (dist.Length() <= R && atom.Position.Z >= -h && atom.Position.Z <= h) { cluster.Add(atom); } } } } } return(cluster); }
/// <summary> /// Refine clusters /// </summary> /// <param name="clusters">Collection of clusters</param> /// <param name="decks">Collection of partial decks used to refine clusters</param> /// <returns>Refined collection of clusters</returns> public List <Cluster> RefineClusters(List <Cluster> clusters, List <PartialDeck> decks) { Trace.Log(""); Trace.Log("*** Refining clusters ***"); // Group decks into clusters var clusterGroups = this.MatchDecksToClusters(clusters, decks); // Generate the next iteration for each cluster foreach (Cluster cluster in clusterGroups.Keys) { Trace.Log(""); Trace.Log("Refining cluster: " + cluster.ToString()); var matchingDecks = clusterGroups[cluster]; var cardCounter = new CardCounter(matchingDecks); this.TraceCardCounts(cardCounter, matchingDecks.Count); Cluster newCluster = new Cluster(); for (int i = 0; i < 30; i++) { newCluster.Add(cardCounter.InstanceCounts[i].CardId); } var diff = cluster.Diff(newCluster); Trace.Log("Diff: " + diff.ToString()); } return(null); }
public bool AddFuelCell(IEnumerable <FuelCell> cells) { if (IsFull) { setTotalPower(); return(true); } foreach (var cell in cells) { Cluster.Add(cell); } if (Cluster.Count > ClusterSize) { throw new ArgumentException(); } if (Cluster.Count % ClusterSize == 0) { IsFull = true; setTotalPower(); return(true); } return(false); }
public bool AddFuelCell(FuelCell cell, bool updatePower = true) { if (IsFull) { if (updatePower) { setTotalPower(); } return(true); } Cluster.Add(cell); if (Cluster.Count > ClusterSize) { throw new ArgumentException(); } if (Cluster.Count % ClusterSize == 0) { IsFull = true; if (updatePower) { setTotalPower(); } return(true); } return(false); }
private void NewAction() { if (cluster_calibration) { Cluster closest = FindClosestCluster(positive_clusters, current_input, true); closest.Add(new Cluster_Point(current_input, current_action), new_point_weight); ++total_cluster_points; Debug.Log("CLUSTER DISTANCES"); for (int i = 0; i < positive_clusters.Count; ++i) { Debug.Log("\t" + i + ": " + positive_clusters[i].point_count + ", " + ClusterPointDistance(positive_clusters[i].centroid, current_input)); } } else { float random_action_thresh = Mathf.Pow(random_action_base, total_cluster_points); if (Random.value <= random_action_thresh) // Pick random action { current_action = (Action)Random.Range(0, (int)Action.Size); Debug.Log("Random: " + current_action); } else // Pick example action { Cluster cp = FindClosestCluster(positive_clusters, current_input, false); Cluster cn = FindClosestCluster(negative_clusters, current_input, false); current_action = DetermineAction(cp, cn); Debug.Log("Cluster: " + current_action); } } }
/// <summary> /// Generates the cluster /// </summary> /// <param name="decks">Collection of partial decks from which to generate cluster</param> /// <param name="totalSampleSize">Total size of the sample</param> /// <returns>The cluster, or null if no cluster was detected</returns> private Cluster GenerateCluster(List <PartialDeck> decks, int totalSampleSize) { var cluster = new Cluster(); while (cluster.Count < 30) { Trace.Log("Processing card #{0} for cluster...", cluster.Count + 1); var filteredDecks = this.deckFilter.FilterByMatchRate(cluster, decks); double filteredDeckPercentage = (double)filteredDecks.Count / totalSampleSize; Trace.Log("Filtered to {0} / {1} decks ({2:P2} of sample).", filteredDecks.Count, totalSampleSize, filteredDeckPercentage); // If we didn't find enough decks to be considered a cluster, bail out if (filteredDeckPercentage < this.options.MinimumClusterSize) { Trace.Log("Could not find a cluster."); return(null); } string nextCardId = this.GetNextCardForCluster(cluster, filteredDecks); cluster.Add(nextCardId); Trace.Log("Added card: {0}", Cards.All[nextCardId].Name); Trace.Log(String.Empty); } return(cluster); }
public Cluster Generate() { Cluster cluster = new Cluster(); for (Int32 i = -M; i <= M; ++i) { for (Int32 j = -M; j <= M; ++j) { for (Int32 k = -M; k <= M; ++k) { var atoms = lattice.GetAtoms(i, j, k); foreach (var atom in atoms) { if (atom.Position.X >= -a && atom.Position.X <= a && atom.Position.Y >= -b && atom.Position.Y <= b && atom.Position.Z >= -c && atom.Position.Z <= c) { cluster.Add(atom); } } } } } return(cluster); }
/** * Get initial cluster based on binary values. */ private Cluster GetInitialCluster(string fileName) { var cluster = new Cluster("lightgray"); // Read dataset using (var reader = new StreamReader(fileName)) { var height = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(','); MaxWidth = values.Length; var width = 0; foreach (var value in values) { // Register coordinates of locations where the value is "1" if (value == "1") { cluster.Add(new Point(width, height)); } width++; } height++; } MaxHeight = height; } return(cluster); }
private static Cluster MergeClusters(Cluster cA, Cluster cB) { cA.Name = cA.Name + "_" + cB.Name; cA.Add(cB.GetVeadGroups(), false); cA.ResetConsensus(); return(cA); }
public void AddFromList() { var initialVeadGroups = ClusterTestHelpers.GetSampleVeadGroups(); var cluster = new Cluster("test", initialVeadGroups); cluster.Add(ClusterTestHelpers.GetSampleVeadGroups(3, 2)); Assert.Equal(3, cluster.GetVeadGroups().Count); }
public void AddNegative() { foreach (Cluster_Point cp in state_buffer) { Cluster closest = FindClosestCluster(negative_clusters, current_input, true); closest.Add(cp, new_point_weight); ++total_cluster_points; } }
public static Cluster GetCluster(ZkClient zkClient) { var cluster = new Cluster(); var nodes = GetChildrenParentMayNotExist(zkClient, BrokerIdsPath); foreach (var node in nodes) { var brokerZkString = ReadData(zkClient, BrokerIdsPath + "/" + node).Item1; cluster.Add(Broker.CreateBroker(int.Parse(node), brokerZkString)); } return(cluster); }
public ModuleProvider() { if (Cluster.Count == 0) { Cluster.Add(new HubCrawlModule() { Name = "Apps", ClusterDLLName = "HubCrawl.Module.Apps.dll", Title = "Apps", ImagePathData = "M119.9996,0L187.33301,20.667028 187.33301,206.66699 119.33293,226.66699 0,182.00028 120.667,197.77798 120.667,36.444982 40.222468,55.555956 40.222468,165.33381 0,181.99999 0,46.000032z" }); } }
public void GetWorstAgreement() { var initialVeadGroups = ClusterTestHelpers.GetSampleVeadGroups(3, 1); var matchVeadGroups = ClusterTestHelpers.GetSampleVeadGroups(3, 1); var nonMatchVeadGroups = ClusterTestHelpers.GetSampleVeadGroups(3, 1, true); var cluster = new Cluster("test", initialVeadGroups); // If there's only one veadgroup, that will by default be the "worst" var worst = cluster.GetWorstAgreement(); Assert.Equal(initialVeadGroups.First(), worst); // This is a tie, they're both the same, first will go cluster.Add(matchVeadGroups); worst = cluster.GetWorstAgreement(); Assert.Equal(initialVeadGroups.First(), worst); // The non-matching group should be the worst agreement cluster.Add(nonMatchVeadGroups); worst = cluster.GetWorstAgreement(); Assert.Equal(nonMatchVeadGroups.First(), worst); }
public void FillCluster(int x, int y) { Coordinates coord; Coordinates[] allNeighbours; MaskMatrixElement currentMatrixElement, neighbourMatrixElement; currentMatrixElement = maskMatrix.matrix[x, y]; clusterElements.Add(maskMatrix.matrix[x, y]); int i = 0; while (i < clusterElements.Count) { currentMatrixElement = clusterElements.ElementAt(i); allNeighbours = getFirstNeighbours(currentMatrixElement.coord.x, currentMatrixElement.coord.y); for (int j = 0; j < allNeighbours.Length; j++) { coord = allNeighbours[j]; if (coord.x >= 0 && coord.y >= 0 && coord.x < n && coord.y < m) { neighbourMatrixElement = maskMatrix.matrix[coord.x, coord.y]; if (!neighbourMatrixElement.coord.isPicked && neighbourMatrixElement.value == 1) { neighbourMatrixElement.setIsPicked(true); currentCluster.Add(neighbourMatrixElement.coord); clusterElements.Add(neighbourMatrixElement); if (!currentCluster.isInThreshold && coord.y < percThresholds[0] && coord.x > percThresholds[1] && coord.x < percThresholds[2]) { currentCluster.isInThreshold = true; } if (coord.x == 0 || coord.x == n - 1 || coord.y == m - 1) { currentCluster.isAtEdge = true; } } else { currentMatrixElement.setIsPicked(true); } } } i++; } clusterElements.Clear(); }
protected void btnSave_Click(Object Sender, EventArgs e) { if (intCluster == 0) { intCluster = oCluster.Add(intRequest, txtName.Text, Int32.Parse(txtNodes.Text), Int32.Parse(txtDR.Text), Int32.Parse(txtHA.Text)); } else { oCluster.Update(intCluster, txtName.Text, Int32.Parse(txtNodes.Text), Int32.Parse(txtDR.Text), Int32.Parse(txtHA.Text)); } oCluster.UpdateLocalNodes(intCluster, 1); Response.Redirect(Request.Path + "?aid=" + intAnswer + "&id=" + intCluster); Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "save", "<script type=\"text/javascript\">RefreshOpeningWindow();window.navigate('" + Request.Path + "?aid=" + intAnswer + "&id=" + intCluster + "');<" + "/" + "script>"); }
// // Helper Methods // internal Cluster Add(T obj) { int capacity = m_elements.Length; if (m_pos == capacity) { m_next = new Cluster(Math.Min(capacity * 2, MaxCapacity)); return(m_next.Add(obj)); } m_elements[m_pos++] = obj; return(this); }
static void Main(string[] args) { Console.WriteLine("Hello World! Starting cluster..."); ILoggerFactory loggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(); }); Log.SetLoggerFactory(loggerFactory); Cluster cluster = new Cluster(); // Test process that becomes unhealthy after 75 seconds LocalProcess localProcessWithBadHealth = GetWorkerProcess(5432, 75); cluster.Add(localProcessWithBadHealth); // Test recycling by cluster after 3 minutes LocalProcess localProcessWithGoodHealth = GetWorkerProcess(5433, -1); localProcessWithGoodHealth.RecyclingIntervalHours = 0.05; cluster.Add(localProcessWithGoodHealth); // Test recycling for busy process after 4.5 minutes LocalProcess localProcessWithGoodHealthButAlwaysBusy = GetWorkerProcess(5434, -1, 1); localProcessWithGoodHealthButAlwaysBusy.RecyclingIntervalHours = 0.075; cluster.Add(localProcessWithGoodHealthButAlwaysBusy); _ = cluster.StartAsync(); Console.WriteLine("Press any key to finish"); Console.ReadKey(); cluster.Abort(); }
private void SplitCluster(Cluster cluster, int splitIndex, out Cluster left, out Cluster right) { left = new Cluster(); right = new Cluster(); for (int i = 0; i < splitIndex; i++) { left.Add(cluster[i]); } for (int i = splitIndex; i < cluster.ItemsCount; i++) { right.Add(cluster[i]); } left.Next = right; right.Previous = left; }
private int BruteForce(char[,] grid) { var clusters = new List <Cluster>(); for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { if (grid[i, j] == '1') { //Console.WriteLine($"found land at {i},{j}"); var coord = new Coord(i, j); var match = clusters.Where(n => n.Neighbors(coord)).ToList(); var count = match.Count(); if (count == 0) { //Console.WriteLine("--no neighboring clusters"); var cluster = new Cluster(); cluster.Add(coord); clusters.Add(cluster); } else if (count == 1) { //Console.WriteLine("--one neighboring clusters"); var cluster = match.Single(); cluster.Add(coord); } else { //Console.WriteLine($"--{count} neighboring clusters"); var first = match.First(); first.Add(coord); match.Remove(first); match.ForEach(n => { first.Merge(n); clusters.Remove(n); }); } } } } return(clusters.Count); }
public Cluster Generate() { Cluster cluster = new Cluster(); for (Int32 i = -M; i <= M; ++i) { for (Int32 j = -M; j <= M; ++j) { for (Int32 k = -M; k <= M; ++k) { var atoms = lattice.GetAtoms(i, j, k); foreach (var a in atoms) { if (a.Position.Length() >= radiusInternal && a.Position.Length() <= radiusExternal) { cluster.Add(a); } } } } } return(cluster); }
public void Add(T item) { if (first == null) { first = new Cluster(); last = first; } if (!last.IsFull) { last.Add(item); } else { var newLast = new Cluster(); newLast.Previous = last; newLast.Add(item); last.Next = newLast; last = newLast; } this.AddToTable(item, last); Interlocked.Increment(ref count); this.ClearCache(); }
public AppProvider() { if (Cluster.Count == 0) { Cluster.Add(new HubCrawlApp() { TileType = HubCrawlAppTileType.Double, Name = "WpfApplication", ClusterDLLName = "WpfApplication.dll" }); Cluster.Add(new HubCrawlApp() { TileType = HubCrawlAppTileType.Double, Name = "WindowsFormsApplication", ClusterDLLName = "WindowsFormsApplication.dll" }); Cluster.Add(new HubCrawlApp() { TileType = HubCrawlAppTileType.Quadruple, Name = "WpfApplication", ClusterDLLName = "WpfApplication.dll" }); } }
private void ExpandCluster(Point p, Cluster c, List<Point> neighbors) { c.Add(p); p.inCluster = true; // foreach (Point neighbor in neighbors) for (int i=0; i<neighbors.Count; ++i) { Point neighbor = neighbors[i]; if (neighbor.Processed == false) { neighbor.Processed = true; var newNeighbors = db.Neighbors(neighbor, Epsilon); if (newNeighbors.Count >= MinPts) { neighbors = neighbors.Union(newNeighbors).ToList(); } } if (neighbor.inCluster == false) { c.Add(neighbor); neighbor.inCluster = true; } } }
public Cluster CreateSolCluster() { Cluster solCluster = new Cluster("Sol Cluster"); Map.Add(solCluster); StarSystem system = null; ProgressionStar star = null; IDictionary <string, string> catalogue = null; system = CreateSolSystem(); solCluster.Add(system); #region Bernard's Star system = new StarSystem("Bernard"); system.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 699"); system.BasicProperties.Add(Constants.PropertyNames.Position, new Point3d(1.5, 0.9, 0.4).ToString()); Map.Add(system); star = new ProgressionStar("Bernard's Star"); star.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 699"); star.BasicProperties.Add(Constants.PropertyNames.StellarClass, "sdM4"); catalogue = new Dictionary <string, string>(); catalogue.Add("HabHyg", "4"); catalogue.Add("Hip", "87937"); star.Properties.AddGroup("Catalogue", catalogue); system.Add(star); solCluster.Add(system); #endregion #region Epsilon Eridani system = new StarSystem("Epsilon Eridani"); system.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 144"); system.BasicProperties.Add(Constants.PropertyNames.Position, new Point3d(-2.1, -0.6, -2.4).ToString()); Map.Add(system); star = new ProgressionStar("Epsilon Eridani"); star.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 144"); star.BasicProperties.Add(Constants.PropertyNames.StellarClass, "K2V"); catalogue = new Dictionary <string, string>(); catalogue.Add("HabHyg", "13"); catalogue.Add("Hip", "16537"); star.Properties.AddGroup("Catalogue", catalogue); system.Add(star); solCluster.Add(system); #endregion #region Procyon system = new StarSystem("Procyon"); system.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 280"); system.BasicProperties.Add(Constants.PropertyNames.Position, new Point3d(-2.8, -1.9, 0.8).ToString()); Map.Add(system); star = new ProgressionStar("Procyon"); star.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 280"); star.BasicProperties.Add(Constants.PropertyNames.StellarClass, "F5IV-V"); catalogue = new Dictionary <string, string>(); catalogue.Add("HabHyg", "18"); catalogue.Add("Hip", "37279"); star.Properties.AddGroup("Catalogue", catalogue); system.Add(star); solCluster.Add(system); #endregion #region Ross system = new StarSystem("Ross"); system.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 447"); system.BasicProperties.Add(Constants.PropertyNames.Position, new Point3d(0, -1.7, 2.9).ToString()); Map.Add(system); star = new ProgressionStar("Pocks"); star.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 447/Ross 128"); star.BasicProperties.Add(Constants.PropertyNames.StellarClass, "M4.5V"); catalogue = new Dictionary <string, string>(); catalogue.Add("HabHyg", "14"); catalogue.Add("Hip", "57548"); star.Properties.AddGroup("Catalogue", catalogue); system.Add(star); solCluster.Add(system); #endregion #region Ceti system = new StarSystem("Ceti"); system.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 65"); system.BasicProperties.Add(Constants.PropertyNames.Position, new Point3d(-0.6, 0.1, -2.5).ToString()); Map.Add(system); star = new ProgressionStar("BL"); star.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 65 A"); star.BasicProperties.Add(Constants.PropertyNames.StellarClass, "dM5.5V"); catalogue = new Dictionary <string, string>(); catalogue.Add("HabHyg", "7"); catalogue.Add("Hip", "-1"); star.Properties.AddGroup("Catalogue", catalogue); system.Add(star); star = new ProgressionStar("UV"); star.BasicProperties.Add(Constants.PropertyNames.Designation, "Gl 65 B"); star.BasicProperties.Add(Constants.PropertyNames.StellarClass, "dM5.5V"); catalogue = new Dictionary <string, string>(); catalogue.Add("HabHyg", "7"); catalogue.Add("Hip", "-1"); star.Properties.AddGroup("Catalogue", catalogue); system.Add(star); solCluster.Add(system); #endregion #region Bridges // Add Bridges ERBridge bridge = ERBridgeHelper.CreateStarSystemBridge(Map, solCluster, "Sol", "Bernard"); solCluster.Add(bridge); bridge = ERBridgeHelper.CreateStarSystemBridge(Map, solCluster, "Sol", "Epsilon Eridani"); solCluster.Add(bridge); bridge = ERBridgeHelper.CreateStarSystemBridge(Map, solCluster, "Sol", "Procyon"); solCluster.Add(bridge); bridge = ERBridgeHelper.CreateStarSystemBridge(Map, solCluster, "Bernard", "Ross"); solCluster.Add(bridge); bridge = ERBridgeHelper.CreateStarSystemBridge(Map, solCluster, "Procyon", "Ceti"); solCluster.Add(bridge); #endregion return(solCluster); }
public void FormClusters() { Items = GameObject.FindGameObjectsWithTag("Item"); for (int i = 0; i < Items.Length; i++) { Cluster cluster = GetClusterOfObject(Items[i]); cluster.type = GetTypeOfObject(Items[i]); if (cluster.type != -1) { for (int j = 0; j < Items.Length; j++) { if (i != j) { if (cluster.type == GetTypeOfObject(Items[j])) { float currentDist = Vector3.Distance(Items[i].transform.position, Items[j].transform.position); Cluster jCluster = GetClusterOfObject(Items[j]); //Если дистанция между объектами меньше минимальной дистанции. if (currentDist <= MinDist) { //Если размер кластера больше размера соседнего кластера того же типа, //то перенести в свой кластер. if (cluster.Size >= jCluster.Size) { jCluster.Remove(Items[j]); cluster.Add(Items[j]); if (jCluster.Empty()) { Clusters.Remove(jCluster); } } else { cluster.Remove(Items[i]); jCluster.Add(Items[i]); break; } } else { //Если объектов больше в своём кластере, чем в соседнем. if (cluster.Size >= jCluster.Size) { //Если в соседнем кластере есть тот же объект, что и своём, то удалить этот объект //И создать новый кластер. if (cluster.Contains(Items[j])) { cluster.Remove(Items[j]); Clusters.Add(new Cluster(Items[j])); } } else { jCluster.Remove(Items[i]); break; } } } } } } //Сформировать кластер если его ещё нет и элементов больше 0 if (!Clusters.Contains(cluster) && cluster.Elements.Count > 0) { Clusters.Add(cluster); } //Если элементов в кластере нет, то удалить его if (cluster.Elements.Count == 0) { Clusters.Remove(cluster); } } CheckSingleClasters(); }
private List<Point> AssignRandomSeeds(int clusterNum) { clusterList = new List<Cluster>(); var randomSeeds = RandomPoints(clusterNum); for(int i=0; i<clusterNum; ++i) { Point seed = randomSeeds[i]; seed.inCluster = true; seed.isSeed = true; seed.clusterIdx = i; Cluster cluster = new Cluster(); cluster.Add(seed); clusterList.Add(cluster); } return randomSeeds; }
protected void CreateClusterAndAddHostsToServer() { ServerName oServerName = new ServerName(0, dsn); Servers oServer = new Servers(0, dsn); Cluster oCluster = new Cluster(0, dsn); int intClass = Int32.Parse(ddlClass.SelectedValue); int intEnv = Int32.Parse(ddlEnvironment.SelectedValue); int intAddress = Int32.Parse(hdnLocation.Value); int intRequestId = Int32.Parse(hdnRequestId.Value); int intVMWareClusterId = 0; int intClusterID = 0; int intSelectedCount = 0; int intSelectedDRCount = 0; DataSet dsAssets = oAsset.GetAssetsByOrder(Int32.Parse(hdnOrderId.Value)); intSelectedCount = dsAssets.Tables[0].Rows.Count; intSelectedDRCount = dsAssets.Tables[0].Rows.Count; intModel = Int32.Parse(ddlModel.SelectedValue); if (intOrderType == (int)AssetSharedEnvOrderType.AddCluster)//for Cluster -Add record in Cluster Table { string strPrefix = "XCV"; string strDatastoreNotify = "xassa3x"; int intServerName = oServerName.Add(intClass, intEnv, intAddress, strPrefix, intProfile, "VMWARE_CLUSTER_IM", 1, dsnServiceEditor); string strClusterName = oServerName.GetName(intServerName, 0); intVMWareClusterId = oVMWare.AddCluster(intParent, intModel, strClusterName, 0, 0, 10000, "", strDatastoreNotify, 1, 500, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 100, 2, 100, 500, 100, 10, 10, 10, 1, 1, 1); foreach (ListItem lstOS in chkFunctionVMWARE.Items) { if (lstOS.Selected) { oVMWare.AddClusterOS(intVMWareClusterId, Int32.Parse(lstOS.Value)); } } intClusterID = oCluster.Add(intRequestId, strClusterName, intSelectedCount, intSelectedDRCount, 0); } else if (intOrderType == (int)AssetSharedEnvOrderType.AddHost) { intVMWareClusterId = Int32.Parse(hdnParentId.Value); } //For Cluster OR Host -Add Server Assets Table if (intOrderType == (int)AssetSharedEnvOrderType.AddCluster || intOrderType == (int)AssetSharedEnvOrderType.AddHost) { int intNumber = 0; int intDomain = 0; int intOS = 0; int intSP = 0; string strNodePrefix = "XNV"; foreach (DataRow drAsset in dsAssets.Tables[0].Rows) { //Mark the Asset to Instock //oAsset.UpdateStatus(Int32.Parse(hdnAssetId.Value), "", (int)AssetStatus.InStock, intProfile, DateTime.Now); intNumber++; int intserverId = oServer.Add(intRequestId, 0, intModel, 0, intClusterID, intNumber, intOS, intSP, 0, intDomain, 0, 1, 0, (intSelectedDRCount > 0 ? 1 : 0), 0, "", 0, 0, 1, 1, 1, 1, 0, (oClass.Get(intClass, "pnc") == "1" ? 1 : 0), intVMWareClusterId, 0); int intAsset = Int32.Parse(drAsset["id"].ToString()); oServer.AddAsset(intserverId, intAsset, intClass, intEnvironment, 0, 0); //oServer.UpdateStep(intserverId, 1); oAsset.Update(intAsset, (int)AssetAttribute.Reserve); //string strHostName = ""; //oAsset.AddStatus(intAsset, strHostName, (int)AssetStatus.Reserved, intProfile, DateTime.Now); //Based on the asset selection create name for hosts //intServerName = oServerName.Add(intClass, intEnv, intAddress, strNodePrefix, intProfile, oAsset.Get(intAsset, "serial"), 1); //string strHostName = oServerName.GetName(intServerName, 0); // } //Set the server step to one DataSet dsServer = oServer.GetRequests(intRequestId, 1); foreach (DataRow dr in dsServer.Tables[0].Rows) { oServer.UpdateStep(Int32.Parse(dr["id"].ToString()), 1); } } ////if (Int32.Parse(rblASEOrderType.SelectedValue) == (int)AssetSharedEnvOrderType.AddHost)//for Host -Add record in Host Table ////{ //// intVMWareClusterId = 123456789; //// int intNumber = 0; //// int intDomain = 0; // josh //// int intOS = 0; // josh //// int intSP = 0; // josh //// string strPrefix = "XNV"; //// int intSelectedDRCount = 0; //// foreach (DataListItem dlItem in dlAssetsSelection.Items) //// { //// HiddenField hdnAssetId = (HiddenField)dlItem.FindControl("hdnAssetId"); //// CheckBox chkSelectAsset = (CheckBox)dlItem.FindControl("chkSelectAsset"); //// if (chkSelectAsset.Checked == true) //// { //// //Mark the Asset to Instock //// //oAsset.UpdateStatus(Int32.Parse(hdnAssetId.Value), "", (int)AssetStatus.InStock, intProfile, DateTime.Now); //// intNumber++; //// int intserverId = oServer.Add(intRequestId, 0, intModel, 0, 0, intNumber, intOS, intSP, 0, intDomain, 0, 1, 0, (intSelectedDRCount > 0 ? 1 : 0), 0, "", 0, 0, 1, 1, 1, 1, 0, (oClass.Get(intClass, "pnc") == "1" ? 1 : 0), intVMWareClusterId, 0); //// int intAsset = Int32.Parse(hdnAssetId.Value); //// oServer.AddAsset(intserverId, intAsset, intClass, intEnvironment, 0, 0); //// //Based on the asset selection create name for hosts //// //intServerName = oServerName.Add(intClass, intEnv, intAddress, strPrefix, intProfile, oAsset.Get(intAsset, "serial"), 1); //// //string strHostName = oServerName.GetName(intServerName, 0); //// //oAsset.AddStatus(intAsset, strHostName, (int)AssetStatus.InUse, intProfile, DateTime.Now); //// } //// } ////} }
public void OnGet() { Dataset = new List <Cluster>(); Dataset.Add(GetInitialCluster("datasets/WineData.csv")); // Add random clusters var kCount = HttpGetQuery("k"); var seedQuery = HttpGetQuery("seed"); if (kCount != "" && seedQuery != "") { var successOne = Int16.TryParse(kCount, out var amount); var successTwo = Int16.TryParse(seedQuery, out var seed); if (successOne && successTwo) { GenerateClusters(amount, seed); } } if (HttpGetQuery("assign") == "true") { var points = new List <Point>(); var clusters = new List <Cluster>(); // Flatten all clusters foreach (var cluster in Dataset) { points = points.Concat(cluster).ToList(); if (cluster.Centroid != null) { clusters.Add(new Cluster(cluster.Color, cluster.Centroid)); } } // Assign points to cluster foreach (var point in points) { double? closestDistance = null; Cluster closestCluster = null; // Check for the closest cluster to the current point position. foreach (var cluster in clusters) { var distance = Math.Sqrt(Math.Pow(cluster.Centroid.X - point.X, 2) + Math.Pow(cluster.Centroid.Y - point.Y, 2)); if (closestDistance == null || distance < closestDistance) { closestDistance = distance; closestCluster = cluster; } } if (closestDistance != null && closestCluster != null) { closestCluster.Add(point); } } // Apply centroids to new clusters collection. Dataset = clusters; } }
public void Clustering(string inputFile, int clusterNum) { int clusterIndex = 0; var clusterOf = new int[db.Count()]; // cluster indexes of points int curCluster = db.Count(); foreach (var pair in db.DistanceSortedList()) { int p1 = pair.Key.id1; int p2 = pair.Key.id2; if (curCluster == clusterNum + 2) break; // If clusterOf[p1] == 0, p1 is not included into any cluster. if (clusterOf[p1] == 0 && clusterOf[p2] == 0) { ++ clusterIndex; clusterOf[p1] = clusterIndex; clusterOf[p2] = clusterIndex; } else if (clusterOf[p1] != 0 && clusterOf[p2] == 0) { clusterOf[p2] = clusterOf[p1]; } else if (clusterOf[p1] == 0 && clusterOf[p2] != 0) { clusterOf[p1] = clusterOf[p2]; } else if (clusterOf[p1] != 0 && clusterOf[p2] != 0) { int clusterIndex1 = clusterOf[p1]; int clusterIndex2 = clusterOf[p2]; if (clusterIndex1 == clusterIndex2) { // no change continue; } int minIndex = (clusterIndex1 < clusterIndex2) ? clusterIndex1 : clusterIndex2; int maxIndex = (clusterIndex1 > clusterIndex2) ? clusterIndex1 : clusterIndex2; for (int i=0; i<clusterOf.Length; ++i) { if (clusterOf[i] == maxIndex) { clusterOf[i] = minIndex; } } } -- curCluster; } HashSet<int> hSet = new HashSet<int>(); foreach (int idx in clusterOf) { hSet.Add(idx); } clusterList = new List<Cluster>(); foreach (int clustIdx in hSet) { Cluster cluster = new Cluster(); for (int i=0; i<clusterOf.Length; ++i) { if (clusterOf[i] == clustIdx) { cluster.Add(db[i]); } } clusterList.Add(cluster); } WriteOutput(inputFile); }
public void AddServer(Server server) { Cluster.Add(server); balancer.AddServer(server); }