Search in sources :

Example 1 with Variable

use of org.tweetyproject.math.term.Variable in project TweetyProject by TweetyProjectTeam.

the class SimulatedAnnealingOnConstrProbEx2 method main.

/**
 * main method
 * @param args arguments
 *
 * @throws GeneralMathException GeneralMathException
 */
public static void main(String[] args) throws ParserException, GeneralMathException {
    // Create toy problem
    OptimizationProblem prob = createConstraintSatProb1();
    // Create starting point; all variables start at 0
    // solve via SimAn
    SimulatedAnnealingOnConstrProb solver = new SimulatedAnnealingOnConstrProb(1000000, 1, 10000);
    Map<Variable, Term> solution = solver.solve(prob);
    System.out.println(solution.toString());
}
Also used : Variable(org.tweetyproject.math.term.Variable) FloatVariable(org.tweetyproject.math.term.FloatVariable) OptimizationProblem(org.tweetyproject.math.opt.problem.OptimizationProblem) Term(org.tweetyproject.math.term.Term)

Example 2 with Variable

use of org.tweetyproject.math.term.Variable in project TweetyProject by TweetyProjectTeam.

the class StochasticLocalSearchOnConstrProbEx method main.

/**
 * main method
 * @param args arguments
 *
 * @throws ParserException ParserException
 * @throws GeneralMathException GeneralMathExceptions
 */
public static void main(String[] args) throws ParserException, GeneralMathException {
    // Create toy problem
    OptimizationProblem prob = createConstraintSatProb1();
    // Create starting point; all variables start at 0
    // solve via SimAn
    StochasticLocalSearchOnConstrProb solver = new StochasticLocalSearchOnConstrProb(5000, 1000, 0.5);
    Map<Variable, Term> solution = solver.solve(prob);
    System.out.println(solution.toString());
}
Also used : Variable(org.tweetyproject.math.term.Variable) FloatVariable(org.tweetyproject.math.term.FloatVariable) OptimizationProblem(org.tweetyproject.math.opt.problem.OptimizationProblem) Term(org.tweetyproject.math.term.Term)

Example 3 with Variable

use of org.tweetyproject.math.term.Variable in project TweetyProject by TweetyProjectTeam.

the class ApacheCommonsCMAESOptimizerEx method main.

/**
 * main method
 * @param args arguments
 *
 * @throws ParserException parserEx
 * @throws IOException IOException
 * @throws GeneralMathException GeneralMathException
 */
public static void main(String[] args) throws ParserException, IOException, GeneralMathException {
    // Create toy problem
    ConstraintSatisfactionProblem prob = createConstraintSatProb1();
    // solve via CommonsCMAESOptimizer
    ApacheCommonsCMAESOptimizer solver = new ApacheCommonsCMAESOptimizer(20, 2000000, 0.00001, false, 10, 1, 0.0001);
    Map<Variable, Term> solution = solver.solve(prob);
    System.out.println(solution.toString());
}
Also used : Variable(org.tweetyproject.math.term.Variable) FloatVariable(org.tweetyproject.math.term.FloatVariable) ConstraintSatisfactionProblem(org.tweetyproject.math.opt.problem.ConstraintSatisfactionProblem) ApacheCommonsCMAESOptimizer(org.tweetyproject.math.opt.solver.ApacheCommonsCMAESOptimizer) Term(org.tweetyproject.math.term.Term)

Example 4 with Variable

use of org.tweetyproject.math.term.Variable in project TweetyProject by TweetyProjectTeam.

the class ApacheCommonsNonLinearConjugateGradientOptimizerEx method main.

/**
 * main method
 * @param args arguments
 * @throws ParserException ParserException
 * @throws IOException IOException
 * @throws GeneralMathException GeneralMathException
 */
public static void main(String[] args) throws ParserException, IOException, GeneralMathException {
    // Create toy problem
    ConstraintSatisfactionProblem prob = createConstraintSatProb1();
    Set<Variable> constr = prob.getVariables();
    // Create starting point; all variables start at 0
    Map<Variable, Term> startingPoint = new HashMap<Variable, Term>();
    for (Variable x : constr) {
        startingPoint.put(x, new IntegerConstant(0));
    }
    // solve via ApacheCommonsNonLinearConjugateGradientOptimizer
    ApacheCommonsNonLinearConjugateGradientOptimizer solver = new ApacheCommonsNonLinearConjugateGradientOptimizer(1000, 0.00001);
    Map<Variable, Term> solution = solver.solve(prob);
    System.out.println(solution.toString());
}
Also used : Variable(org.tweetyproject.math.term.Variable) FloatVariable(org.tweetyproject.math.term.FloatVariable) ConstraintSatisfactionProblem(org.tweetyproject.math.opt.problem.ConstraintSatisfactionProblem) HashMap(java.util.HashMap) Term(org.tweetyproject.math.term.Term) ApacheCommonsNonLinearConjugateGradientOptimizer(org.tweetyproject.math.opt.solver.ApacheCommonsNonLinearConjugateGradientOptimizer) IntegerConstant(org.tweetyproject.math.term.IntegerConstant)

Example 5 with Variable

use of org.tweetyproject.math.term.Variable in project TweetyProject by TweetyProjectTeam.

the class ApacheCommonsSimplexEx2 method main.

/**
 * main method
 * @param args arguments
 * @throws ParserException ParserException
 * @throws IOException IOException
 * @throws GeneralMathException GeneralMathException
 */
public static void main(String[] args) throws ParserException, IOException, GeneralMathException {
    // Create toy problem
    OptimizationProblem prob = createConstraintSatProb1();
    Set<Variable> constr = prob.getVariables();
    // Create starting point; all variables start at 0
    Map<Variable, Term> startingPoint = new HashMap<Variable, Term>();
    for (Variable x : constr) {
        startingPoint.put(x, new IntegerConstant(0));
    }
    // solve via BfggsSolver
    ApacheCommonsSimplex solver = new ApacheCommonsSimplex();
    Map<Variable, Term> solution = solver.solve(prob);
    System.out.println(solution.toString());
}
Also used : FloatVariable(org.tweetyproject.math.term.FloatVariable) Variable(org.tweetyproject.math.term.Variable) HashMap(java.util.HashMap) ApacheCommonsSimplex(org.tweetyproject.math.opt.solver.ApacheCommonsSimplex) OptimizationProblem(org.tweetyproject.math.opt.problem.OptimizationProblem) Term(org.tweetyproject.math.term.Term) IntegerConstant(org.tweetyproject.math.term.IntegerConstant)

Aggregations

Variable (org.tweetyproject.math.term.Variable)62 Term (org.tweetyproject.math.term.Term)59 HashMap (java.util.HashMap)44 FloatVariable (org.tweetyproject.math.term.FloatVariable)42 FloatConstant (org.tweetyproject.math.term.FloatConstant)40 OptimizationProblem (org.tweetyproject.math.opt.problem.OptimizationProblem)29 IntegerConstant (org.tweetyproject.math.term.IntegerConstant)28 GeneralMathException (org.tweetyproject.math.GeneralMathException)26 ConstraintSatisfactionProblem (org.tweetyproject.math.opt.problem.ConstraintSatisfactionProblem)18 Equation (org.tweetyproject.math.equation.Equation)14 ArrayList (java.util.ArrayList)10 Inequation (org.tweetyproject.math.equation.Inequation)9 Statement (org.tweetyproject.math.equation.Statement)8 ProbabilisticConditional (org.tweetyproject.logics.pcl.syntax.ProbabilisticConditional)7 PossibleWorld (org.tweetyproject.logics.pl.semantics.PossibleWorld)7 Collection (java.util.Collection)6 Test (org.junit.Test)6 PclBeliefSet (org.tweetyproject.logics.pcl.syntax.PclBeliefSet)6 PlFormula (org.tweetyproject.logics.pl.syntax.PlFormula)6 GeneralConstraintSatisfactionProblem (org.tweetyproject.math.opt.problem.GeneralConstraintSatisfactionProblem)6