Esempio n. 1
0
/*
 * The hash table is to keep track of leaves which have already been displayed
 * to the user.
 */
int main(int argc, char **argv)
{
	int			i;

	/* Initialize space for blacklist hash table */
	if(hcreate(10000)==0) {
		fputs("Cannot create hash table.\n",stderr);
		return(EX_UNAVAILABLE);
	}

	i=0;
	do {
		if(read_pkglist(i++))
			break;
		if(display_menu())
			break;
		if(remove_packages())
			break;
		free_menu();
	} while(keep_going());
	hdestroy();

	fputs("\nProgram Terminated Successfully\n",stderr);
	return(0);
}
Esempio n. 2
0
/**
 * Build the ADTree, assuming no covariates.
 * 
 */
void ADTree::processNoCov(){
	int temp_precon=0; long temp_attr=0; short temp_val=0;
	Condition::comparison temp_test = Condition::GE;
	double new_score_t, new_score_f;
	double *temp_weights = new double[5];

	AD_Rule *temp_r;
	Condition *c;

	//
	// READY TO RUN
	//
	while(keep_going()){
			
		double z = 0;
		// Get minimum score
		//z = minimize(&temp_precon, &temp_attr, &temp_test, &temp_val);
		z = minimize_ordinal(temp_precon, temp_attr, temp_test, temp_val);
		// Calc new scores
	
		weights(temp_weights, temp_precon, temp_attr, temp_test, temp_val);
		
		if(param_reader->get_verbosity() > 2){
			cout << "Num nodes: " << tree.node_size() << " score " << z << endl;
			cout << "Attribute: " << temp_attr << endl;
		}
		
		// Using 0.0005 for now, will change later to be 1/size
		new_score_t = .5 * log((temp_weights[0]+this->fudge) / (temp_weights[1]+this->fudge));
		new_score_f = .5 * log((temp_weights[2]+this->fudge) / (temp_weights[3]+this->fudge));
		
		// Make new rule and make two new preconditions.
		c = new Condition;
		c->attribute_index = temp_attr;
		c->genotype_conditional = temp_test;
		c->genotype_reference = temp_val;

		vector<Condition> condi_v = tree.precon_at(temp_precon)->conditions;
		Precondition *p1 = new Precondition;
		p1->conditions = condi_v;

		temp_r = new AD_Rule(*p1,*c, new_score_t, new_score_f);
		(*p1).conditions.push_back(*c);

		tree.push_node(*temp_r, (temp_precon+1)/2);

		tree.push_precondition(*p1);
		// Make a precondition with this set.
		c->inverse();
		condi_v = tree.precon_at(temp_precon)->conditions;
		Precondition *p2 = new Precondition;
		p2->conditions = condi_v;
		p2->conditions.push_back(*c);
		tree.push_precondition(*p2);
		delete c;
		delete p1;
		delete p2;
		delete temp_r;

		// Reweight data.
		for(unsigned int i=0; i < weight_vec.size(); i++){
			weight_vec.at(i) *= exp(-1.0 * tree.evaluate_on_last(data->get_data(i)) * data->get_phenotype(i));
		}
	}


	delete[] (temp_weights);	
}