Package net.sf.tweety.math.examples
Class KnapSack
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet<ElementOfCombinatoricsProb>
-
- net.sf.tweety.math.opt.problem.CombinatoricsProblem
-
- net.sf.tweety.math.examples.KnapSack
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<ElementOfCombinatoricsProb>,Collection<ElementOfCombinatoricsProb>,Set<ElementOfCombinatoricsProb>
public class KnapSack extends CombinatoricsProblem
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class net.sf.tweety.math.opt.problem.CombinatoricsProblem
MAXIMIZE, MINIMIZE
-
-
Constructor Summary
Constructors Constructor Description KnapSack(ArrayList<ElementOfCombinatoricsProb> elements, Term maxWeight)
-
Method Summary
Modifier and Type Method Description ArrayList<ElementOfCombinatoricsProb>createRandomNewSolution(ArrayList<ElementOfCombinatoricsProb> currSol)doubleevaluate(ArrayList<ElementOfCombinatoricsProb> sol)booleanisValid(ArrayList<ElementOfCombinatoricsProb> sol)doublesumOfValues(ArrayList<ElementOfCombinatoricsProb> sol)doublesumOfWeights(ArrayList<ElementOfCombinatoricsProb> sol)-
Methods inherited from class net.sf.tweety.math.opt.problem.CombinatoricsProblem
createDifference, formNeighborhood
-
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size, spliterator
-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Constructor Detail
-
KnapSack
public KnapSack(ArrayList<ElementOfCombinatoricsProb> elements, Term maxWeight)
-
-
Method Detail
-
sumOfWeights
public double sumOfWeights(ArrayList<ElementOfCombinatoricsProb> sol)
- Specified by:
sumOfWeightsin classCombinatoricsProblem- Parameters:
sol- is the solution to be viewd- Returns:
- if the solution sol is valid under the constraints of the problem
-
sumOfValues
public double sumOfValues(ArrayList<ElementOfCombinatoricsProb> sol)
-
createRandomNewSolution
public ArrayList<ElementOfCombinatoricsProb> createRandomNewSolution(ArrayList<ElementOfCombinatoricsProb> currSol)
- Specified by:
createRandomNewSolutionin classCombinatoricsProblem
-
isValid
public boolean isValid(ArrayList<ElementOfCombinatoricsProb> sol)
- Specified by:
isValidin classCombinatoricsProblem
-
evaluate
public double evaluate(ArrayList<ElementOfCombinatoricsProb> sol)
- Specified by:
evaluatein classCombinatoricsProblem
-
-