Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a C program that can read any simple data file. The program should contai

ID: 3883499 • Letter: C

Question

Create a C program that can read any simple data file. The program should contain code that randomly initialize a genetic algorithm population (say population size = 100) and compute the makespans of the population. Select the best schedule according to makespans and output the schedule and its makespan.

For example suppose you have a file named text.txt that contains the following data.

3 2 //This first row indicates the number of jobs and the number of machines

0 5 1 10 //These other row represents a specific job combined by (machine-id, job-duration) pairs.

0 10 1 5

0 1 1 4

The output would be

21 //This first line indicates the optimization criterion

2 0 0 1 1 6 //This second line is the makespan computed from the schedule

2 1 0 6 1 16   //This is the flowshop schedule combined by (job-id, start-time) pairs

Explanation / Answer

#include int main() { int num; FILE *fptr; if ((fptr = fopen("C:\program.txt","r")) == NULL){ printf("Error! opening file"); // Program exits if the file pointer returns NULL. exit(1); } fscanf(fptr,"%d", &num); printf("Value of n=%d", num); fclose(fptr); return 0; }