public STAGE(STAGE s) { rows = new List <List <ROW> >(); for (int i = 0; i < s.rows.Count; i++) { List <ROW> copy = s.rows[i].Select(row => new ROW(row)).ToList(); this.rows.Add(new List <ROW>(copy)); } }
private void PRINTSTAGE(STAGE s) { for (int i = 0; i < s.rows.Count; i++) { for (int j = 0; j < s.rows[i].Count; j++) { Console.Write(s.rows[i][j].s + " "); Console.Write("isTICKED?" + " " + s.rows[i][j].isTicked + " "); List <int> t = s.rows[i][j].minTermsIncluded; for (int l = 0; l < t.Count; l++) { Console.Write(t[l] + " "); } Console.WriteLine(""); } Console.WriteLine(""); } }
public void solve(bool convert = true) { if (minterms_orig.Count == 0) { return; } MERGE(); List <Tuple <int, ROW> > stage0 = new List <Tuple <int, ROW> >(); STAGE tStage = new STAGE(); List <ROW> temp = new List <ROW>(), temp1 = new List <ROW>(), temp2 = new List <ROW>(); List <List <ROW> > tRows = new List <List <ROW> >(), curRows = new List <List <ROW> >(); List <List <ROW> > newRows = new List <List <ROW> >(); for (int i = 0; i < minTerms.Count; i++) { int countOne = COUNTONE(DECTOBIN(minTerms[i])); stage0.Add(new Tuple <int, ROW>(countOne, new ROW(DECTOBIN(minTerms[i]), minTerms[i]))); } stage0.Sort((x, y) => (y.Item1.CompareTo(x.Item1))); stage0.Reverse(); temp.Add(new ROW(stage0[0].Item2)); for (int i = 1; i < stage0.Count; i++) { if (stage0[i].Item1 == stage0[i - 1].Item1) { temp.Add(new ROW(stage0[i].Item2)); } else { tRows.Add(new List <ROW>(temp)); temp.Clear(); temp.Add(new ROW(stage0[i].Item2)); } } tRows.Add(new List <ROW>(temp)); tStage.rows = tRows; tStage.rows = tRows.Select(x => x.ToList()).ToList(); for (int i = 0; i < tStage.rows.Count; i++) { tStage.rows[i].Reverse(); } stages.Add(new STAGE(tStage)); int mainFlag; while (true) { tStage.rows.Clear(); STAGE curStage = new STAGE(stages[stages.Count - 1]); stages.RemoveAt(stages.Count - 1); curRows = new List <List <ROW> >(); for (int i = 0; i < curStage.rows.Count; i++) { List <ROW> copy = curStage.rows[i].Select(row => new ROW(row)).ToList(); curRows.Add(new List <ROW>(copy)); } mainFlag = 0; newRows.Clear(); for (int i = 1; i < curRows.Count; i++) { temp2.Clear(); for (int j = 0; j < curRows[i - 1].Count; j++) { for (int k = 0; k < curRows[i].Count; k++) { int flag = CHECK(curRows[i - 1][j].s, curRows[i][k].s); if (flag == 1) { mainFlag = 1; ROW tRow = new ROW(MERGEROW(curRows[i - 1][j], curRows[i][k])); curRows[i - 1][j].isTicked = 1; curRows[i][k].isTicked = 1; temp2.Add(new ROW(tRow)); } } } newRows.Add(new List <ROW>(temp2)); } for (int i = 0; i < newRows.Count; i++) { List <ROW> copy = newRows[i].Select(row => new ROW(row)).ToList(); tStage.rows.Add(new List <ROW>(copy)); } for (int i = 0; i < curRows.Count; i++) { List <ROW> copy = curRows[i].Select(row => new ROW(row)).ToList(); curStage.rows.Add(new List <ROW>(copy)); } stages.Add(new STAGE(curStage)); if (mainFlag == 0) { break; } stages.Add(new STAGE(tStage)); } for (int i = 0; i < stages.Count; i++) { stages[i].rows.RemoveRange(0, stages[i].rows.Count / 2); } UNIQUE(); ESSENTIALPI(); for (int i = 0; i < essentialPi.Count; i++) { raw_essentialPi.Add(new List <string>(essentialPi[i])); } if (convert) { CONVERT(); } }