Tarefa12/main.cpp
void compute_path(vector<Flight>& flights, string to, vector<Travel>& travels, unsigned long t_min, unsigned long t_max, Parameters parameters){
	vector<Travel> final_travels;
	
	//double start = omp_get_wtime();
	int aux = travels.size();

	while(travels.size() > 0)
	{
  		Travel travel = travels.back();
    	Flight current_city = travel.flights.back();
    	travels.pop_back();
    	//First, if a direct flight exist, it must be in the final travels
    	if(current_city.to == to)
		{
    	  final_travels.push_back(travel);
    	}
		else
		{
			//otherwise, we need to compute a path
      		
			#pragma omp parallel for schedule(guided)
			for(unsigned int i=0; i<flights.size(); i++)
			{
				Flight flight = flights[i];
				if(
					flight.from == current_city.to &&
	   				flight.take_off_time >= t_min &&
	   				flight.land_time <= t_max &&
	   				(flight.take_off_time > current_city.land_time) &&
	   				flight.take_off_time - current_city.land_time <= parameters.max_layover_time &&
	   				nerver_traveled_to(travel, flight.to)
				)
				{
	  				Travel newTravel = travel;
	  				newTravel.flights.push_back(flight);
	  				if(flight.to == to)
					{
	    				final_travels.push_back(newTravel);
	  				}
					else
					{
	    				travels.push_back(newTravel);
	  				}
				}
    		}
		}
	aux = travels.size();
	}
	
	//double end = omp_get_wtime();
	//printf("\nTempo do while = %f", end - start);
	
	travels = final_travels;
}
/**
 * \fn void compute_path(vector<Flight>& flights, string to, vector<Travel>& travels, unsigned long t_min, unsigned long t_max, Parameters parameters)
 * \brief Computes a path from a point A to a point B. The flights must be scheduled between t_min and t_max. It is also important to take the layover in consideration.
 * 	You should try to improve and parallelize this function. A lot of stuff can probably done here. You can do almost what you want but the program output must not be modified.
 * \param flights All the flights that are available.
 * \param to The destination.
 * \param travels The list of possible travels that we are building.
 * \param t_min You must not be in a plane before this value (epoch)
 * \param t_max You must not be in a plane after this value (epoch)
 * \param parameters The program parameters
 */
\fn void compute_path(vector& flights, string to, vector& travels, unsigned long t_min, unsigned long t_max, Parameters parameters)
\brief Computes a path from a point A to a point B. The flights must be scheduled between t_min and t_max. It is also important to take the layover in consideration.
You should try to improve and parallelize this function. A lot of stuff can probably done here. You can do almost what you want but the program output must not be modified.
\param flights All the flights that are available.
\param to The destination.
\param travels The list of possible travels that we are building.
\param t_min You must not be in a plane before this value (epoch)
\param t_max You must not be in a plane after this value (epoch)
\param parameters The program parameters
\ fn void compute_path ( vector& flights string to vector& travels unsigned long t_min unsigned long t_max Parameters parameters ) \ brief Computes a path from a point A to a point B . The flights must be scheduled between t_min and t_max . It is also important to take the layover in consideration . You should try to improve and parallelize this function . A lot of stuff can probably done here . You can do almost what you want but the program output must not be modified . \ param flights All the flights that are available . \ param to The destination . \ param travels The list of possible travels that we are building . \ param t_min You must not be in a plane before this value ( epoch ) \ param t_max You must not be in a plane after this value ( epoch ) \ param parameters The program parameters
void compute_path(vector<Flight>& flights, string to, vector<Travel>& travels, unsigned long t_min, unsigned long t_max, Parameters parameters){
	vector<Travel> final_travels;
	int aux = travels.size();
	while(travels.size() > 0)
	{
  		Travel travel = travels.back();
    	Flight current_city = travel.flights.back();
    	travels.pop_back();
    	if(current_city.to == to)
		{
    	  final_travels.push_back(travel);
    	}
		else
		{
			#pragma omp parallel for schedule(guided)
			for(unsigned int i=0; i<flights.size(); i++)
			{
				Flight flight = flights[i];
				if(
					flight.from == current_city.to &&
	   				flight.take_off_time >= t_min &&
	   				flight.land_time <= t_max &&
	   				(flight.take_off_time > current_city.land_time) &&
	   				flight.take_off_time - current_city.land_time <= parameters.max_layover_time &&
	   				nerver_traveled_to(travel, flight.to)
				)
				{
	  				Travel newTravel = travel;
	  				newTravel.flights.push_back(flight);
	  				if(flight.to == to)
					{
	    				final_travels.push_back(newTravel);
	  				}
					else
					{
	    				travels.push_back(newTravel);
	  				}
				}
    		}
		}
	aux = travels.size();
	}
	travels = final_travels;
}
void compute_path ( vector < Flight > & flights , string to , vector < Travel > & travels , unsigned long t_min , unsigned long t_max , Parameters parameters ) { vector < Travel > final_travels ; int aux = travels . size ( ) ; while ( travels . size ( ) > 0 ) { Travel travel = travels . back ( ) ; Flight current_city = travel . flights . back ( ) ; travels . pop_back ( ) ; if ( current_city . to == to ) { final_travels . push_back ( travel ) ; } else { #pragma  omp parallel for schedule(guided) for ( unsigned int i = 0 ; i < flights . size ( ) ; i ++ ) { Flight flight = flights [ i ] ; if ( flight . from == current_city . to && flight . take_off_time >= t_min && flight . land_time <= t_max && ( flight . take_off_time > current_city . land_time ) && flight . take_off_time - current_city . land_time <= parameters . max_layover_time && nerver_traveled_to ( travel , flight . to ) ) { Travel newTravel = travel ; newTravel . flights . push_back ( flight ) ; if ( flight . to == to ) { final_travels . push_back ( newTravel ) ; } else { travels . push_back ( newTravel ) ; } } } } aux = travels . size ( ) ; } travels = final_travels ; }
\fn void compute_path(vector<Flight>& flights, string to, vector<Travel>& travels, unsigned long t_min, unsigned long t_max, Parameters parameters)
 \brief Computes a path from a point A to a point B.
\ fn void compute_path ( vector<Flight > & flights string to vector<Travel > & travels unsigned long t_min unsigned long t_max Parameters parameters ) \ brief Computes a path from a point A to a point B .
//double start = omp_get_wtime(); //First, if a direct flight exist, it must be in the final travels //otherwise, we need to compute a path //double end = omp_get_wtime(); //printf("\nTempo do while = %f", end - start);