summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/optimization/stopCriteria/CompositeStopingCriteria.java
blob: 15760f181d497c3298e4765eb95a3e7823c8b67d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package optimization.stopCriteria;

import java.util.ArrayList;

import optimization.gradientBasedMethods.Objective;

public class CompositeStopingCriteria implements StopingCriteria {
	
	ArrayList<StopingCriteria> criterias;
	
	public CompositeStopingCriteria() {
		criterias = new ArrayList<StopingCriteria>();
	}
	
	public void add(StopingCriteria criteria){
		criterias.add(criteria);
	}
	
	public boolean stopOptimization(Objective obj){
		for(StopingCriteria criteria: criterias){
			if(criteria.stopOptimization(obj)){
				return true;
			}
		}
		return false;
	}
	
	public void reset(){
		for(StopingCriteria criteria: criterias){
			criteria.reset();
		}
	}
}