Esempio n. 1
0
        public SatResult Solve()
        {
            movesHistory         = new List <DataPoint>();
            currentConfiguration = Options.StartingPositionStrategy.GetStartingPosition(this);
            BestConfiguration    = new SatConfiguration {
                Instance = SatInstance, Score = 0, Valuations = new List <bool>(new bool[SatInstance.Literals.Count])
            };
            CurrentTemperature   = Options.BaseStartingTemperature * SatInstance.GetSumOfWeights();
            ScaledMinTemperature = Options.MinimalTemperature * SatInstance.GetSumOfWeights();
            NumberOfSteps        = 0;

            var solutionLoopCount = 0;

            while (!RunSolutionLoop() && solutionLoopCount < MAX_RESTART_COUNT - 1)
            {
                solutionLoopCount++;
                CurrentTemperature        = Options.BaseStartingTemperature * SatInstance.GetSumOfWeights();
                AcceptedDuringEquilibrium = 0;
                EquilibriumSteps          = 0;
                //Options.BaseEquilibriumSteps = (int) (Options.BaseEquilibriumSteps * EQUILIBRIUM_RESTART_MULTIPLIER);
            }


            return(new SatResult {
                Configuration = BestConfiguration,
                SatInstance = SatInstance,
                NumberOfSteps = this.NumberOfSteps,
                MovesHistory = movesHistory,
                RestartCount = solutionLoopCount,
                BestConfigurationFoundAt = bestConfigurationFoundAt,
                NumberOfUnsatisfiedClauses = BestConfiguration.NumberOfUnsatisfiedClauses()
            });
        }
        public float CalculateScore(SatConfiguration configuration, SimulatedAnnealingSolver solver)
        {
            //Base score is the optimalization value
            float score = configuration.GetOptimalizationValue();

            //Penalize the score based on the number of unsatisfied clauses
            score -= configuration.NumberOfUnsatisfiedClauses() * solver.Options.PenaltyMultiplier;
            return(score);
        }
Esempio n. 3
0
        public float CalculateScore(SatConfiguration configuration, SimulatedAnnealingSolver solver)
        {
            //Base score is the optimalization value
            float score = configuration.GetOptimalizationValue();

            //Make the score negative if it is unsatisfiable
            if (!configuration.IsSatisfiable())
            {
                score -= configuration.Instance.GetSumOfWeights();
            }

            //Penalize the score further based on the number of unsatisfied clauses
            score -= configuration.NumberOfUnsatisfiedClauses() * solver.Options.PenaltyMultiplier;
            return(score);
        }