Beispiel #1
0
//archiver proposed by Laumanns and Zenklusken
//param - the solution to be submitted to the archiver
bool Repository::MGAArchiver(Solution &candidate){
	insert(candidate);
	organize();
	int b = compute_b_mga(solutions, actualSize);
	int index_removed = -1;
	while(index_removed==-1){
		for(int i = actualSize-1; i>=0;i--){
			double box_i[objectiveNumber];
			box_mga(solutions[i], box_i, b, objectiveNumber);
			for(int j = actualSize-1; j>=0;j--){
				if(i!=j){
					double box_j[objectiveNumber];
					box_mga(solutions[j], box_j, b, objectiveNumber);
					int comparation = dominance(box_i, box_j, objectiveNumber);
					if(comparation == -1 || isEqual(box_i, box_j, objectiveNumber) ){
						index_removed = i;
						break;
					}
				}
			}
			//if(index_removed!=-1){
			//	break;
			//}
		}
		b--;
	}
	
	bool ret=true;
	if(candidate.isEqual(solutions[index_removed]))
		ret=false;
	
	exclude(index_removed);
	
	return ret;
}
Beispiel #2
0
//tries to add a solution in the repository if it is non-dominated
//param - the candidate solution to be inserted in the repository
 bool Repository::add(Solution &candidate){
	bool isDominated=false;
	bool equal=false;
	int dom;
	bool enteredArchive=false;
	if(actualSize==0){ //if the repository is empty, insert the solution
		insert(candidate);
		enteredArchive=true;
	}else{
		for(int s=0;s<repositorySize+1;s++){
			if(controlSolutions[s]){//if this solution is valid
				if(!candidate.isEqual(getSolution(s))){ //if the solutions are not equal
					//verify the dominance relation between two vectors
					//return 1 if sol1 dominates sol2, -1 if sol2 dominates sol1, 0 if they do not dominate each other, 2 if they are equal
					if(!strcmp(archiverType, "pbi") || !strcmp(archiverType, "tch")  || !strcmp(archiverType, "wcp") || !strcmp(archiverType, "wsum") || !strcmp(archiverType, "r-ideal"))//repositories based on decomposition, if decomposition do not check dominance
						dom=0;
					else
						dom=dominance(candidate.objectiveVector, getSolution(s).objectiveVector, objectiveNumber);

					if(dom == 1){//if the candidate dominates the solution in the repository
						exclude(s);
					}else{
						if(dom == -1){//if a solution in the repository dominates the candidate
							isDominated=true;
							if(vectorZero(getSolution(s).objectiveVector, objectiveNumber)){
								fprintf(stderr, "\nERROR! Trying to insert in the repository a solution whose objectives are all 0\n");
								exit(1);
							}
							break;
						}
					}
				}else{ //if the solutions are equal, discard the candidate
					equal=true;
					break;
				}
			}
		}

		if(!isDominated && !equal){ //if the solution is non-dominated
			candidate.dominated=false;
			if(actualSize<repositorySize){//if the repository is not empty nor full
				insert(candidate);//insert the solution
				enteredArchive=true;
			}else{ //if the repository is full
				enteredArchive=archiver(candidate);
			}
		}else{
			candidate.dominated=true;
			enteredArchive=false;
		}
	}
	return enteredArchive;
}
Beispiel #3
0
//add a solution ignoring whether the repository is full or not
void Repository::forceAdd(Solution &candidate){
	bool isDominated=false;
	bool equal=false;
	if(actualSize==0){ //if the repository is empty, insert the solution
		insert(candidate);
	}else{
		for(int s=0;s<repositorySize+1;s++){
			if(controlSolutions[s]){//if this solution is valid
				if(!candidate.isEqual(getSolutions()[s])){ //if the solutions are not equal
					//verify the dominance relation between two vectors
					//return 1 if sol1 dominates sol2, -1 if sol2 dominates sol1, 0 if they do not dominate each other, 2 if they are equal
					if(dominance(candidate.objectiveVector, getSolution(s).objectiveVector, objectiveNumber) == 1){//if the candidate dominates the solution in the repository
						exclude(s);
					}else{
						if(dominance(candidate.objectiveVector, getSolution(s).objectiveVector, objectiveNumber) == -1){//if a solution in the repository dominates the candidate
							isDominated=true;
							break;
						}
					}
				}else{ //if the solutions are equal, discard the candidate
					equal=true;
					break;
				}
			}
		}

		if(!isDominated && !equal){ //if the solution is non-dominated
			if(actualSize<repositorySize+1){//if there is memory left
				insert(candidate);//insert the solution
			}else{ //if there is not memory left
				fprintf(stderr,"REPOSITORY MEMORY UNAVAILABLE, INCREASE THE REPOSITORY MAXIMUM SIZE\n");
				//exit(1);
			}
		}
	}
}
std::string ColorDiscriminator::Dominator::dominance_str() const {
  return MakeString() << std::fixed << std::setw(3) << std::setprecision(0) <<
      100 * dominance() << " %";
}