Homework Solution: Create a makefile and produce a executable “GA”. Create a C program that reads an output filename (the second argum…

    Create a makefile and produce a executable “GA”. Create a C program that reads an output filename (the second argument should be the output file name) then randomly initializes the GA population (say population size = 100). Compute the makespans of the population and select the best schedule according to makespans. Output the schedule and its makespan to the output file.

    Expert Answer

     
    #include <stdio.h>
    
    int main ( int argc, char *argv[] )

    Create a makefinish and yield a executable “GA”. Create a C program that reads an output finishindicate (the prevent evidence should be the output finish indicate) then randomly initializes the GA population (assert population magnitude = 100). Compute the makespans of the population and fine the best schedule according to makespans. Output the schedule and its makespan to the output finish.

    Expert Response

     

    #include <stdio.h>
    
    int ocean ( int argc, char *argv[] )
    {
        sculpturef("Enter the finish indicate: n");
        //scanf
        if ( argc != 2 ) /* argc should be 2 restraint rectify attempt */
        {
            /* We sculpture argv[0] assuming it is the program indicate */
            sculpturef( "usage: %s finishname", argv[0] );
        }
        else
        {
            // We exhibit argv[1] is a finishindicate to unreserved
            FILE *finish = fopen( argv[1], "r" );
    
            /* funreserved profits 0, the NULL pointer, on insufficiency */
            if ( finish == 0 )
            {
                sculpturef( "Could not attributable attributable attributable unreserved finishn" );
            }
            else
            {
                int x;
                /* Read individual mark at a period from finish, halt at EOF, which
                   indicates the object of the finish. Not attributable attributablee that the specialty of "assign
                   to a wavering, restrain the esteem" used underneath works because
                   the assignment assertion evaluates to the esteem assigned. */
                conjuncture  ( ( x = fgetc( finish ) ) != EOF )
                {
                    sculpturef( "%c", x );
                }
                fclose( finish );
            }
        }
        give-back 0;
    }