public void SetCost(int c1, int s1, int c2, int s2) { if (s1 == 0 || s2 == 0) { return; } Shoot[] shoots = new Shoot[2]; shoots[0] = kmeans.clusters[c1].members[s1 - 1]; shoots[1] = kmeans.clusters[c2].members[s2 - 1]; //DBA.CostPath DPtable = DBA.DpMatching(inputshoots[shoot1].acc, inputshoots[shoot2].acc); // DBA.CalcCost(a,b) aからみたbのコスト 長さはa double[][] costs = new double[2][]; Chart[] charts = { chart1, chart2 }; for (int c = 0; c < 2; ++c) { //shoot[0] and shoot[1] compare //cost[0]=(0,1) cost[1]=(1,0) costs[c] = DBA.CalcCost(shoots[c].acc, shoots[(c + 1) % 2].acc).cost; string legend4 = "cost"; charts[c].Series.Add(legend4); charts[c].Series[legend4].ChartType = SeriesChartType.Line; // 折れ線グラフ for (int i = 0; i < shoots[c].acc.Length; i++) { //shoot1における、shoot2からみたコスト //shoot2における、shoot1からみたコスト charts[c].Series[legend4].YAxisType = AxisType.Secondary; charts[c].Series[legend4].Points.AddXY(shoots[c].time[i], costs[c][i]); //cost Console.WriteLine("cost i :" + i + " time:" + shoots[c].time[i]); } } }
public void SetData(int cidA, int cidB) { //クラスタ同士のコスト 格納 double[] cost = DBA.CalcCost(kmeans.clusters[cidA].centroid.DBAacc, kmeans.clusters[cidB].centroid.DBAacc).cost; double dist = DBA.CalcCost(kmeans.clusters[cidA].centroid.DBAacc, kmeans.clusters[cidB].centroid.DBAacc).dist; chart1.Series.Clear(); chart1.ChartAreas.Clear(); // ChartにSeriesを追加します string legend1 = "X"; string legend2 = "Y"; string legend3 = "Z"; string legend4 = "cost"; chart1.Series.Add(legend1); chart1.Series.Add(legend2); chart1.Series.Add(legend3); chart1.Series.Add(legend4); chart1.Series[legend1].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.Series[legend2].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.Series[legend3].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.Series[legend4].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.ChartAreas.Add(new ChartArea("Area1")); chart1.ChartAreas["Area1"].AxisX.Title = "time"; chart1.ChartAreas["Area1"].AxisY.Title = "degree"; { //クラスタ1(基準) Cluster ca = kmeans.clusters[cidA]; //クラスタ2(比較したいもの) Cluster cb = kmeans.clusters[cidB]; //クラスタ間の距離(総コスト) distNum.Text = dist.ToString(); //double dt = 0.1; //double[] dtCost = new double[s.acc.Length]; for (int i = 0; i < ca.centroid.DBAacc.Length - 1; i++) { chart1.Series[legend1].Points.AddXY(ca.centroid.DBAtime[i], ca.centroid.DBAacc[i].x); //X chart1.Series[legend2].Points.AddXY(ca.centroid.DBAtime[i], ca.centroid.DBAacc[i].y); //Y chart1.Series[legend3].Points.AddXY(ca.centroid.DBAtime[i], ca.centroid.DBAacc[i].z); //Z } for (int i = 0; i < ca.centroid.DBAtime.Length; i++) { //costの軸は2軸目(右側のY軸目盛り)で表示 chart1.Series[legend4].YAxisType = AxisType.Secondary; //caを基準にグラフを表示 chart1.Series[legend4].Points.AddXY(ca.centroid.DBAtime[i], cost[i]); //cost } } }
void CalcFinalDistance() { foreach (Cluster c in clusters) { foreach (Shoot s in c.members) { //コスト計算 s.cost = DBA.CalcCost(s.acc, c.centroid.DBAacc).cost; } } }
public void SetData(int cid, int sid) { chart1.Series.Clear(); chart1.ChartAreas.Clear(); // ChartにSeriesを追加します string legend1 = "X"; string legend2 = "Y"; string legend3 = "Z"; string legend4 = "cost"; chart1.Series.Add(legend1); chart1.Series.Add(legend2); chart1.Series.Add(legend3); chart1.Series.Add(legend4); chart1.Series[legend1].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.Series[legend2].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.Series[legend3].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.Series[legend4].ChartType = SeriesChartType.Line; // 折れ線グラフ chart1.ChartAreas.Add(new ChartArea("Area1")); chart1.ChartAreas["Area1"].AxisX.Title = "time"; chart1.ChartAreas["Area1"].AxisY.Title = "degree"; //クラスタ型から拾ってくる //Centroid のグラフ出力 sid == 0 if (sid == 0) { Cluster c = kmeans.clusters[cid]; for (int i = 0; i < c.centroid.DBAacc.Length; i++) { chart1.Series[legend1].Points.AddY(c.centroid.DBAacc[i].x); //X chart1.Series[legend2].Points.AddY(c.centroid.DBAacc[i].y); //Y chart1.Series[legend3].Points.AddY(c.centroid.DBAacc[i].z); //Z } laShoot.Text = "Centroid"; laShootNum.Text = ""; distNum.Text = " "; } //各クラスタに属する射の入力データのグラフ出力 Centroidに距離が近い順(Sort済み) else { //クラスタ番号cidのクラスタ Cluster c = kmeans.clusters[cid]; //クラスタ番号cidのメンバー Shoot s = c.members[sid - 1]; DBAShoot dba = c.centroid; laShoot.Text = "Shoot"; laShootNum.Text = s.shootnumber.ToString(); distNum.Text = DBA.CalcCost(s.acc, dba.DBAacc).dist.ToString(); //double dt = 0.1; //double[] dtCost = new double[s.acc.Length]; for (int i = 0; i < s.acc.Length - 1; i++) { chart1.Series[legend1].Points.AddXY(s.time[i], s.acc[i].x); //X chart1.Series[legend2].Points.AddXY(s.time[i], s.acc[i].y); //Y chart1.Series[legend3].Points.AddXY(s.time[i], s.acc[i].z); //Z } //costのグラフも表示 for (int i = 0; i < s.cost.Length; i++) { ////chart1.Series[legend4].Points.AddY(s.path[i]); //cost //dtCost[i] = (s.cost[i] - s.cost[i - 1]) / dt; //dtCost[i] = s.cost[i]; //costの軸は2軸目(右側のY軸目盛り)で表示 double[] DBAcost = DBA.CalcCost(s.acc, dba.DBAacc).cost; chart1.Series[legend4].YAxisType = AxisType.Secondary; //chart1.Series[legend4].Points.AddXY(dba.DBAtime[i], s.cost[i]); //cost chart1.Series[legend4].Points.AddXY(s.time[i], DBAcost[i]); //cost } } }