use of org.tweetyproject.math.opt.problem.OptimizationProblem in project TweetyProject by TweetyProjectTeam.
the class SimulatedAnnealingOnConstrProbEx2 method createConstraintSatProb1.
/**
* constrcutor
* @return problem
*/
public static OptimizationProblem createConstraintSatProb1() {
FloatVariable m1 = new FloatVariable("Machine 1", -100, 100);
FloatVariable m2 = new FloatVariable("Machine 2", -100, 100);
Inequation constr1 = new Inequation(m1, new IntegerConstant(10), 3);
Inequation constr2 = new Inequation(m2, new IntegerConstant(12), 1);
Inequation constr3 = new Inequation(m1, new IntegerConstant(50), 1);
Inequation constr4 = new Inequation(m2, new IntegerConstant(0), 3);
Collection<Statement> constraints = new ArrayList<Statement>();
constraints.add(constr1);
constraints.add(constr2);
constraints.add(constr3);
constraints.add(constr4);
OptimizationProblem prob = new OptimizationProblem(0);
prob.addAll(constraints);
// Target funcion = (m1+1)^2+m2^2
Term opt = new Sum(new Power(new Sum(m1, new IntegerConstant(1)), new IntegerConstant(2)), new Power(m2, new IntegerConstant(2)));
((OptimizationProblem) prob).setTargetFunction(opt);
return prob;
}
use of org.tweetyproject.math.opt.problem.OptimizationProblem 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());
}
use of org.tweetyproject.math.opt.problem.OptimizationProblem 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());
}
use of org.tweetyproject.math.opt.problem.OptimizationProblem in project TweetyProject by TweetyProjectTeam.
the class StochasticLocalSearchOnConstrProbEx method createConstraintSatProb1.
/**
* constructor
* @return problem
*/
public static OptimizationProblem createConstraintSatProb1() {
FloatVariable m1 = new FloatVariable("Machine 1", -100, 100);
FloatVariable m2 = new FloatVariable("Machine 2", -100, 100);
Inequation constr1 = new Inequation(m1, new IntegerConstant(10), 3);
Inequation constr2 = new Inequation(m2, new IntegerConstant(12), 1);
Inequation constr3 = new Inequation(m1, new IntegerConstant(50), 1);
Inequation constr4 = new Inequation(m2, new IntegerConstant(0), 3);
Collection<Statement> constraints = new ArrayList<Statement>();
constraints.add(constr1);
constraints.add(constr2);
constraints.add(constr3);
constraints.add(constr4);
OptimizationProblem prob = new OptimizationProblem(0);
prob.addAll(constraints);
// Target funcion = (m1+1)^2+m2^2
Term opt = new Sum(new Power(new Sum(m1, new IntegerConstant(1)), new IntegerConstant(2)), new Power(m2, new IntegerConstant(2)));
((OptimizationProblem) prob).setTargetFunction(opt);
return prob;
}
use of org.tweetyproject.math.opt.problem.OptimizationProblem in project TweetyProject by TweetyProjectTeam.
the class ApacheCommonsCMAESOptimizerEx method createConstraintSatProb1.
/**
* constructor
* @return the problem
*/
public static ConstraintSatisfactionProblem createConstraintSatProb1() {
FloatVariable m1 = new FloatVariable("Machine 1", -50, 100);
FloatVariable m2 = new FloatVariable("Machine 2", -50, 100);
// Target funcion = (m1+1)^2+m2^2
Term opt = new Sum(new Power(new Sum(m1, new FloatConstant(-1)), new IntegerConstant(2)), new Power(m2, new IntegerConstant(2)));
OptimizationProblem prob = new OptimizationProblem();
((OptimizationProblem) prob).setTargetFunction(opt);
return prob;
}
Aggregations