Example #1
0
        private void CalculateAppearances()
        {
            for (int i = 0; i < variables.List.Count; i++)
            {
                appearances.Add(new VariableAppearance(i, 0));
            }

            foreach (var clause in clauses.List)
            {
                foreach (int var in clause)
                {
                    int index = SatSolver.GetVar(var);
                    appearances[index].Count++;
                }
            }

            appearances = appearances.OrderBy(o => - o.Variable).ToList();
        }
Example #2
0
        private void InitVarCounts()
        {
            varCount.Clear();
            for (int c = 0; c < clauses.List.Count; c++)
            {
                if (clauses.List[c] == null)
                {
                    continue;
                }

                int len = clauses.List[c].Count;
                if (len < 2)
                {
                    continue;
                }

                foreach (int variable in clauses.List[c])
                {
                    Key key = new Key(len, SatSolver.GetVar(variable));

                    if (variables[key.Variable] != 0)
                    {
                        continue;
                    }

                    if (varCount.ContainsKey(key))
                    {
                        varCount[key]++;
                    }
                    else
                    {
                        varCount.Add(key, 1);
                    }
                }
            }
        }
Example #3
0
 public UnitClause(int value)
 {
     this.Value = value;
     this.Index = SatSolver.GetVar(value);
 }