public static SatConfiguration RandomConfiguration(SatInstance instance, Random random) { var satConfiguration = new SatConfiguration(); satConfiguration.Instance = instance; for (int i = 0; i < instance.Literals.Count; i++) { satConfiguration.Valuations.Add(Convert.ToBoolean(random.Next(0, 2))); } return(satConfiguration); }
public bool IsSatisfiable(SatConfiguration configuration) { foreach (var ratedLiteral in RatedLiterals) { //XOR - the valuation must be true AND negation false, or valuation must be false AND negation true if (configuration.Valuations[ratedLiteral.Literal.Id - 1] ^ ratedLiteral.IsNegated) { return(true); } } return(false); }
public SatConfiguration(SatConfiguration other) { Valuations = new List <bool>(other.Valuations); Instance = other.Instance; }