示例#1
0
 var nextAnswer = function () {
   var formula = self.solution.getFormula();
   var newSolution = logic.solveAssuming(Logic.not(formula));
   if (newSolution) {
     self.setSolution(newSolution);
     logic.forbid(formula);
   }
   return newSolution;
 };
示例#2
0
 _.each(analysis.constraints, function (c) {
   // We logically require that EITHER a constraint is marked as a
   // conflict OR it comes from a package version that is not selected
   // OR its constraint formula must be true.
   // (The constraint formula says that if toPackage is selected,
   // then a version of it that satisfies our constraint must be true.)
   logic.require(
     Logic.or(c.conflictVar,
              c.fromVar ? Logic.not(c.fromVar) : [],
              self.getConstraintFormula(c.toPackage, c.vConstraint)));
 });
示例#3
0
var _getConstraintFormula = function (toPackage, vConstraint) {
  var self = this;

  var targetVersions = self.getVersions(toPackage);
  var okVersions = getOkVersions(toPackage, vConstraint, targetVersions);

  if (okVersions.length === targetVersions.length) {
    return Logic.TRUE;
  } else {
    return Logic.or(Logic.not(toPackage), okVersions);
  }
};
示例#4
0
 _.each(analysis.packagesWithNoAllowedVersions, function (constrs, p) {
   var newSolution = logic.solveAssuming(Logic.not(p));
   if (newSolution) {
     self.setSolution(newSolution);
     logic.forbid(p);
   } else {
     var error =
       'No version of ' + p + ' satisfies all constraints: ' +
         _.map(constrs, function (constr) {
           return '@' + constr.constraintString;
         }).join(', ');
     error += '\n' + self.listConstraintsOnPackage(p);
     self.errors.push(error);
   }
 });