public void Graph_calc(List <country> Gomer, matrix graph) { for (int i = 0; i < Gomer.Count; i++) { for (int j = 0; j < Gomer.Count; j++) { double[] veci = { Gomer[i].power, Gomer[i].technology, Gomer[i].enviroment, Gomer[i].educ_tech, Gomer[i].educ_cult }; double[] vecj = { Gomer[j].power, Gomer[j].technology, Gomer[j].enviroment, Gomer[j].educ_tech, Gomer[j].educ_cult }; graph.self[i, j] = (indicator_func(Gomer[i].educ_cult, Gomer[j].educ_cult) + indicator_func(Gomer[i].educ_tech, Gomer[j].educ_tech) + indicator_func(Gomer[i].enviroment, Gomer[j].enviroment) + indicator_func(Gomer[i].power, Gomer[j].power) + indicator_func(Gomer[i].technology, Gomer[j].technology)) * normal(veci, vecj) * 0.2f / (indicator_func(Gomer[i].educ_cult, Gomer[j].educ_cult) + indicator_func(Gomer[i].educ_tech, Gomer[j].educ_tech) + indicator_func(Gomer[i].enviroment, Gomer[j].enviroment) + indicator_func(Gomer[i].power, Gomer[j].power) + indicator_func(Gomer[i].technology, Gomer[j].technology + 1.0f)); if (graph.self[i, j] > 0) { //MessageBox.Show(graph.self[i, j].ToString(), "Graph calc", MessageBoxButtons.OK); } else { graph.self[i, j] = 0.0f; } } } }
public void Change_education(country temp) { matrix temptemp = new matrix(temp.population.size_first, temp.population.size_second); for (int i = 0; i < 10; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { //temp.population.self[i, j] = temp.ch_educ.self[i, k]*temp.population.self[k,j]; temptemp.self[i, j] += temp.ch_educ.self[j, k] * temp.population.self[i, k]; } } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 3; j++) { temp.population.self[i, j] = Math.Round(temptemp.self[i, j]); } } }
private void button1_Click(object sender, EventArgs e) { Graph_calc(Gomer, graph); defeintion_coeff_matrix(Gomer); List <matrix> temp = new List <matrix>(); for (int l = 0; l < Gomer.Count; l++) { input = new matrix(10, 3); for (int k = 0; k < Gomer.Count; k++) { if (k == l) { continue; } for (int i = 0; i < 10; i++) { for (int j = 0; j < 3; j++) { input.self[i, j] = Math.Round(graph.self[l, k] * Gomer[l].population.self[i, j] * coeff(i, j)); if (input.self[i, j] > Gomer[l].population.self[i, j]) { input.self[i, j] = Gomer[l].population.self[i, j]; Gomer[l].population.self[i, j] = 0; } else { Gomer[l].population.self[i, j] = Gomer[l].population.self[i, j] - input.self[i, j]; } } } } temp.Add(input); } for (int l = 0; l < Gomer.Count; l++) { Arrival_immigrant(Gomer[l], temp[l]); } MessageBox.Show(Gomer[0].population.self[0, 0].ToString() + "\t" + Gomer[0].population.self[0, 1].ToString() + "\t" + Gomer[0].population.self[0, 2].ToString() + "\n" + Gomer[0].population.self[1, 0].ToString() + "\t" + Gomer[0].population.self[1, 1].ToString() + "\t" + Gomer[0].population.self[1, 2].ToString() + "\n" + Gomer[0].population.self[2, 0].ToString() + "\t" + Gomer[0].population.self[2, 1].ToString() + "\t" + Gomer[0].population.self[2, 2].ToString() + "\n" + Gomer[0].population.self[3, 0].ToString() + "\t" + Gomer[0].population.self[3, 1].ToString() + "\t" + Gomer[0].population.self[3, 2].ToString() + "\n" + Gomer[0].population.self[4, 0].ToString() + "\t" + Gomer[0].population.self[4, 1].ToString() + "\t" + Gomer[0].population.self[4, 2].ToString() + "\n" + Gomer[0].population.self[5, 0].ToString() + "\t" + Gomer[0].population.self[5, 1].ToString() + "\t" + Gomer[0].population.self[5, 2].ToString(), "Result " + Gomer[0].name_country, MessageBoxButtons.OK); MessageBox.Show(Gomer[1].population.self[0, 0].ToString() + "\t" + Gomer[1].population.self[0, 1].ToString() + "\t" + Gomer[1].population.self[0, 2].ToString() + "\n" + Gomer[1].population.self[1, 0].ToString() + "\t" + Gomer[1].population.self[1, 1].ToString() + "\t" + Gomer[1].population.self[1, 2].ToString() + "\n" + Gomer[1].population.self[2, 0].ToString() + "\t" + Gomer[1].population.self[2, 1].ToString() + "\t" + Gomer[1].population.self[2, 2].ToString() + "\n" + Gomer[1].population.self[3, 0].ToString() + "\t" + Gomer[1].population.self[3, 1].ToString() + "\t" + Gomer[1].population.self[3, 2].ToString() + "\n" + Gomer[1].population.self[4, 0].ToString() + "\t" + Gomer[1].population.self[4, 1].ToString() + "\t" + Gomer[1].population.self[4, 2].ToString() + "\n" + Gomer[1].population.self[5, 0].ToString() + "\t" + Gomer[1].population.self[5, 1].ToString() + "\t" + Gomer[1].population.self[5, 2].ToString(), "Result " + Gomer[1].name_country, MessageBoxButtons.OK); MessageBox.Show(Gomer[2].population.self[0, 0].ToString() + "\t" + Gomer[2].population.self[0, 1].ToString() + "\t" + Gomer[2].population.self[0, 2].ToString() + "\n" + Gomer[2].population.self[1, 0].ToString() + "\t" + Gomer[2].population.self[1, 1].ToString() + "\t" + Gomer[2].population.self[1, 2].ToString() + "\n" + Gomer[2].population.self[2, 0].ToString() + "\t" + Gomer[2].population.self[2, 1].ToString() + "\t" + Gomer[2].population.self[2, 2].ToString() + "\n" + Gomer[2].population.self[3, 0].ToString() + "\t" + Gomer[2].population.self[3, 1].ToString() + "\t" + Gomer[2].population.self[3, 2].ToString() + "\n" + Gomer[2].population.self[4, 0].ToString() + "\t" + Gomer[2].population.self[4, 1].ToString() + "\t" + Gomer[2].population.self[4, 2].ToString() + "\n" + Gomer[2].population.self[5, 0].ToString() + "\t" + Gomer[2].population.self[5, 1].ToString() + "\t" + Gomer[2].population.self[5, 2].ToString(), "Result " + Gomer[2].name_country, MessageBoxButtons.OK); /*List<distribution> county = new List<distribution>();*/ /* * try * { * DialogResult rt=MessageBox.Show("Are you sure that you want run analysis?", "Attention", MessageBoxButtons.YesNo); * if (rt == DialogResult.Yes) * { * try * { * string sql = "select * from country"; * //distribution temp = new distribution(); * SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\fyodo\Desktop\diplom-master\diplom\myDiplom\myDiplom\bin\Debug\DATABASE.MDF;Integrated Security=True"); * //C:\USERS\FYODO\DESKTOP\DIPLOM-MASTER\DIPLOM\MYDIPLOM\MYDIPLOM\DATABASE.MDF * //C:\Users\FLoginov\Source\Repos\diplom\diplom\myDiplom\myDiplom\Database.mdf * conn.Open(); * * SqlCommand command = new SqlCommand(sql, conn); * SqlDataReader reader = command.ExecuteReader(); * * //List<string> data = new List<string>(); * * while (reader.Read()) * { * MessageBox.Show(reader.GetString(0)+" "+reader.GetString(1) ,"data", MessageBoxButtons.OK); * //data.Add(reader[0].ToString()); * } * //MessageBox.Show(data[1], "", MessageBoxButtons.OK); * * reader.Close(); * conn.Close(); * Close(); * } * catch * { * MessageBox.Show("Error", caption: "You have a problem with database connection", buttons: MessageBoxButtons.OK); * } * } * else * { * MessageBox.Show("You're right!", "Congratulations", MessageBoxButtons.OK); * } * } * catch * { * * } */ }