Пример #1
0
void Lottery::run() {
	srand(time(NULL));

	generateTeams();

	generateLotteryNumbers();
	assignTeams();

	generateOutputFile();
}
Пример #2
0
void CRebuildGraph::CompareAndGenerateResults(SettingsSimulation settingsSimulation,
                                              gslGraph *targetGraph,
                                              gslGraph *bestGraph,
                                              char* inputFilename,
                                              time_t timeStart,
                                              double Tk,
                                                double *&bestBC,
                                              double costBest,
                                            double &compareResult,
                                            char *outputGraphFilename
                                              ){
    CFuncTrace lFuncTrace(false,string("CRebuildGraph::CompareAndGenerateResults"));
    time_t timeEnd;
    gsl_matrix *targetGraphGsl = gsl_matrix_calloc(targetGraph->getOrder(), targetGraph->getOrder());
    gsl_matrix *bestGraphGsl = gsl_matrix_calloc(bestGraph->getOrder(), bestGraph->getOrder());
    
    targetGraph->graphToGsl(targetGraphGsl);
    bestGraph->graphToGsl(bestGraphGsl);
    
    
    compareResult = this->compareMatrix(targetGraphGsl, bestGraphGsl);
    
    // Processing tasks accomplished
    // Showing results
    
    timeEnd=time(NULL);
    
    lFuncTrace.trace(CTrace::TRACE_DEBUG,"RESULTS:\n");
    lFuncTrace.trace(CTrace::TRACE_DEBUG,"CPU time needed: %f seconds\n",difftime(timeEnd,timeStart));
    // printf("Output file: %s\n",outputFilename);
    
    double *targetBC = NULL;
    {
        graphIndicator * graphIndicator = FactoryMethodGraphIndicator::createGraphIndicator(settingsSimulation.graphProperty,targetGraph);
              targetBC = graphIndicator->calculateIndicatorWithReescale(settingsSimulation.reescale);
        delete  graphIndicator;
    }
    
    
    generateOutputFile(targetGraph,inputFilename,  Tk, costBest,targetBC,
                       bestBC, timeStart, timeEnd,settingsSimulation);
    
    lFuncTrace.trace(CTrace::TRACE_DEBUG,"Reconstructed graph file: %s",outputGraphFilename);
    
    bestGraph->printMyGraph(outputGraphFilename,settingsSimulation.outputFormatGraphResultAdjList);

    gsl_matrix_free(bestGraphGsl);
    gsl_matrix_free(targetGraphGsl);
    
}
int main(int argc, char * argv[])
{
    //checks to make sure that there are 2 arguments - one for input and output
    inputCheck(argv);
    
    //Get the input file name...
    char *inputFileName = *(argv + 1);
    char *outputFileName = *(argv + 2);
    
    //Find out how many students are on the input file...
    int numberOfStudents = getRecordCount(inputFileName);
    
    //Create the number of students depending on the record count...
    Student listOfStudents[numberOfStudents];
    createStudents(listOfStudents, numberOfStudents);
    
    //Read the data of the input file...
    FILE *myFile = openFile(inputFileName);
    
    //Fill out all the student's info...
    fillStudentRecord(myFile, listOfStudents, numberOfStudents);
    
    //sortStudents using the array of student struct
    sortStudents(listOfStudents, numberOfStudents);
    
    //Calculate each student's GPA and recorded in the structure...
    getGPA(listOfStudents, numberOfStudents);
    
    //Calculate each student's Letter Grade and record in the structure...
    getGrade(listOfStudents, numberOfStudents);
    
    //Create ClassGrade structure pointer...
    ClassGrade *classGrade;
    classGrade = (ClassGrade *)malloc((sizeof classGrade) * 20);
    
    //Call functions to calculate the scores...
    getScoreAverage(listOfStudents, classGrade, numberOfStudents);
    getMinScore(listOfStudents, classGrade, numberOfStudents);
    getMaxScore(listOfStudents, classGrade, numberOfStudents);
    
    //Generate and output file with the student grade information
    generateOutputFile(outputFileName, inputFileName, listOfStudents, numberOfStudents);
    
    //Print out student's info...
    printAllStudents(listOfStudents, classGrade, numberOfStudents, inputFileName, outputFileName);
    
    return 0;
}
Пример #4
0
void
AGActivityGen::makeActivityTrips(int days, int beginSec, int endSec) {
    durationInDays = days;
    beginTime = beginSec;
    endTime = endSec;
    /**
     * making the activity trips
     */
    AGActivities acts(&city, durationInDays + 1);
    acts.generateActivityTrips();

    /**
     * validating the trips with the simulation's time limits
     */
    //list<Trip>* trips = &(acts.trips);
    std::list<AGTrip> expTrips;
    std::map<std::string, int> carUsed;
    std::list<AGTrip>::iterator it;
    //multiplication of days
    for (it = acts.trips.begin(); it != acts.trips.end(); ++it) {
        if (it->isDaily()) {
            for (int currday = 1; currday < durationInDays + 2; ++currday) {
                AGTrip tr(it->getDep(), it->getArr(), it->getVehicleName(), it->getTime(), currday);
                tr.setType(it->getType());
                if (carUsed.find(tr.getVehicleName()) != carUsed.end()) {
                    ++carUsed.find(tr.getVehicleName())->second;
                } else {
                    carUsed[tr.getVehicleName()] = 1;
                }
                std::ostringstream os;
                os << tr.getVehicleName() << ":" << carUsed.find(tr.getVehicleName())->second;
                tr.setVehicleName(os.str());
                tr.addLayOverWithoutDestination(*it); //intermediate destinations are taken in account too
                varDepTime(tr); //slight variation on each "default" car
                if (timeTripValidation(tr)) {
                    expTrips.push_back(tr);
                }
                //else
                //	std::cout << "trop tard 1 pour " << tr.getVehicleName() << " " << tr.getTime() << " day: " << tr.getDay() << std::endl;
            }
        } else {
            AGTrip tr(it->getDep(), it->getArr(), it->getVehicleName(), it->getTime(), it->getDay());
            tr.setType(it->getType());
            if (carUsed.find(tr.getVehicleName()) != carUsed.end()) {
                ++carUsed.find(tr.getVehicleName())->second;
            } else {
                carUsed[tr.getVehicleName()] = 1;
            }
            std::ostringstream os;
            os << tr.getVehicleName() << ":" << carUsed.find(tr.getVehicleName())->second;
            tr.setVehicleName(os.str());
            tr.addLayOverWithoutDestination(*it); //intermediate destinations are taken in account too
            varDepTime(tr); //slight variation on each "default" car
            if (timeTripValidation(tr)) {
                expTrips.push_back(tr);
            }
            //else
            //	std::cout << "trop tard 2 pour " << tr.getVehicleName() << " " << tr.getTime() << " day: " << tr.getDay() << std::endl;
        }
    }

    std::cout << "total trips generated: " << acts.trips.size() << std::endl;
    std::cout << "total trips finally taken: " << expTrips.size() << std::endl;

    /**
     * re-ordering of trips: SUMO needs routes ordered by departure time.
     */
    expTrips.sort(); //natural order of trips
    std::cout << "...sorted by departure time.\n" << std::endl;

    /**
     * trip file generation
     */
    generateOutputFile(expTrips);
}