use of org.tweetyproject.math.term.FloatConstant 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;
}
use of org.tweetyproject.math.term.FloatConstant in project TweetyProject by TweetyProjectTeam.
the class ApacheCommonsSimplexEx method createConstraintSatProb1.
/**
* constructor
* @return the problem
*/
public static ConstraintSatisfactionProblem createConstraintSatProb1() {
// Define the constraints (all are equations)
IntegerVariable m1 = new IntegerVariable("Maschine 1");
IntegerVariable m2 = new IntegerVariable("Maschine 2");
Inequation constr1 = new Inequation(m1, new IntegerConstant(10), 1);
Inequation constr2 = new Inequation(m2, new IntegerConstant(12), 1);
Inequation constr3 = new Inequation(m1, new IntegerConstant(0), 3);
Inequation constr4 = new Inequation(m2, new IntegerConstant(0), 3);
Inequation constr5 = new Inequation(m1.add(m2), new IntegerConstant(16), 0);
Collection<Statement> constraints = new ArrayList<Statement>();
constraints.add(constr1);
constraints.add(constr2);
constraints.add(constr3);
constraints.add(constr4);
constraints.add(constr5);
OptimizationProblem prob = new OptimizationProblem(1);
prob.addAll(constraints);
// Define targetfunction
Term opt = new Sum(new Sum(m1, new FloatConstant(1)), m2);
prob.setTargetFunction(opt);
return prob;
}
use of org.tweetyproject.math.term.FloatConstant in project TweetyProject by TweetyProjectTeam.
the class HessianGradientSolverEx method createConstraintSatProb1.
/**
* constructor
* @return problem
*/
public static ConstraintSatisfactionProblem createConstraintSatProb1() {
FloatVariable m1 = new FloatVariable("Machine 1");
FloatVariable m2 = new FloatVariable("Machine 2");
// 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;
}
use of org.tweetyproject.math.term.FloatConstant in project TweetyProject by TweetyProjectTeam.
the class KnapSack_solvedWithTabuSearch method main.
/**
* main method
* @param args arguments
*/
public static void main(String[] args) {
// define the maximum weight
FloatConstant maxl = new FloatConstant(15);
// create a list of items defined by weight and value
ArrayList<ElementOfCombinatoricsProb> elems = new ArrayList<ElementOfCombinatoricsProb>();
for (int i = 0; i < 10; i++) {
ElementOfCombinatoricsProb x = new ElementOfCombinatoricsProb(new ArrayList<Term>());
x.components.add(new IntegerConstant((int) (Math.random() * 10) + 1));
x.components.add(new IntegerConstant((int) (Math.random() * 10) + 1));
elems.add(x);
}
KnapSack test = new KnapSack(elems, maxl);
// solve the problem with a tabu size of 5, max 100000 iterations and max 2000 iterations without an improvement to the best solution
TabuSearch ts = new TabuSearch(1000000, 50, 1000);
ArrayList<ElementOfCombinatoricsProb> mySol = ts.solve(test);
System.out.println("MySol: ");
for (ElementOfCombinatoricsProb i : mySol) System.out.print(i.components + " ");
}
use of org.tweetyproject.math.term.FloatConstant in project TweetyProject by TweetyProjectTeam.
the class LpSolverEx method createConstraintSatProb1.
/**
* constructor
* @return problem
*/
public static ConstraintSatisfactionProblem createConstraintSatProb1() {
// Define the constraints (all are equations)
FloatVariable m1 = new FloatVariable("Maschine1");
FloatVariable m2 = new FloatVariable("Maschine2");
Inequation constr1 = new Inequation(m1, m2, 1);
Inequation constr2 = new Inequation(m2, new FloatConstant(11), 1);
Inequation constr3 = new Inequation(m1, new FloatConstant(0), 3);
Inequation constr4 = new Inequation(m2, new FloatConstant(0), 3);
Collection<Statement> constraints = new ArrayList<Statement>();
constraints.add(constr1);
constraints.add(constr2);
constraints.add(constr3);
constraints.add(constr4);
OptimizationProblem prob = new OptimizationProblem(1);
prob.addAll(constraints);
// Define targetfunction
Term opt = m1;
prob.setTargetFunction(opt);
return prob;
}
Aggregations