-1

I have a problem where my code below was working prefect with the arg commands 100 100 0 100 0 100 0.5 but now it just says make: 100: Not a directory

package MonteCarloMini;

import java.util.concurrent.RecursiveTask;
import java.util.concurrent.ForkJoinPool;
import java.util.Random;


public class MonteCarloMinimizationParallel extends RecursiveTask<int[]>{

    static final boolean DEBUG = false;
    static long startTime = 0;
    static long endTime = 0;

    private static void tick() {
        startTime = System.currentTimeMillis();
    }

    private static void tock() {
        endTime = System.currentTimeMillis();
    }

    public static void main(String[] args) {

        int rows, columns;
        double xmin, xmax, ymin, ymax;
        TerrainArea terrain;
        double search_density;
        int num_searches;
        Random random = new Random();
    

        if (args.length !=7) {
            System.out.println("Incorrect number of command line arguments provided.");
            System.exit(0);
        }

        rows = Integer.parseInt(args[0]);
        columns = Integer.parseInt(args[1]);
        xmin = Double.parseDouble(args[2]);
        xmax = Double.parseDouble(args[3]);
        ymin = Double.parseDouble(args[4]);
        ymax = Double.parseDouble(args[5]);
        search_density = Double.parseDouble(args[6]);
        terrain = new TerrainArea(rows, columns, xmin, xmax, ymin, ymax);
        num_searches = (int) (rows*columns*search_density);

        SearchParallel[] searches = new SearchParallel[num_searches];


        for (int i=0; i<num_searches; i++) {
            searches[i] = new SearchParallel(i+1, random.nextInt(rows), random.nextInt(columns), terrain);
        }

        if(DEBUG) {
            /* Print initial values */
            System.out.printf("Number searches: %d\n", num_searches);
            //terrain.print_heights();
        }

        //start the timer
        tick();

        ForkJoinPool fjPool = new ForkJoinPool();
        SearchTask task = new SearchTask(searches, 0, num_searches);
        int result[] = fjPool.invoke(task);

    //stop the timer
        tock();


        if(DEBUG) {
        /* print final state */
            terrain.print_heights();
            terrain.print_visited();
        }
    
        System.out.printf("Run parameters\n");
        System.out.printf("\t Rows: %d, Columns: %d\n", rows, columns);
        System.out.printf("\t x: [%f, %f], y: [%f, %f]\n", xmin, xmax, ymin, ymax );
    System.out.printf("\t Search density: %f (%d searches)\n", search_density,num_searches );

    /*  Total computation time */
    System.out.printf("Time: %d ms\n",endTime - startTime );
    int tmp=terrain.getGrid_points_visited();
    System.out.printf("Grid points visited: %d  (%2.0f%s)\n",tmp,(tmp/(rows*columns*1.0))*100.0, "%");
    tmp=terrain.getGrid_points_evaluated();
    System.out.printf("Grid points evaluated: %d  (%2.0f%s)\n",tmp,(tmp/(rows*columns*1.0))*100.0, "%");

    /* Results*/
    System.out.printf("Global minimum: %d at x=%.1f y=%.1f\n\n", result[0], terrain.getXcoord(searches[task.finder].getPos_row()), terrain.getYcoord(searches[task.finder].getPos_col()) );
    System.out.println("Min: " + result[0] + " Finder: " + task.finder); //result[1]); task.lo searcg[task.finder]

}


    private static class SearchTask extends RecursiveTask<int[]> {
        
        private final SearchParallel[] searches;
        protected final int lo, hi;
        final int SEQUENTIAL_CUTOFF=1000;
        int finder = 1;


        public SearchTask(SearchParallel[] searches, int lo, int hi) {
            this.searches = searches;
            this.lo = lo;
            this.hi = hi;
        }
        

        @Override
        protected int[] compute() {

            if (hi-lo <= SEQUENTIAL_CUTOFF) {
                    int min = Integer.MAX_VALUE;

                    for (int i = lo; i<hi; i++) {
                        int local_min = searches[i].findValleys();

                        if ((!searches[i].isStopped()) && (local_min < min)) {
                            min = local_min;
                            finder = i;
                        }
                        
                        if(DEBUG) System.out.println("Search " + searches + " finished at  " + lo + " in " + searches[i].getSteps());

                    }

                    return new int[]{min, finder};
                }

                else {
                    int mid = (lo+hi) / 2;
                    SearchTask left = new SearchTask(searches, lo, mid);
                    SearchTask right = new SearchTask(searches,mid, hi);
                    left.fork();
                    int[] rightResult = right.compute();
                    int[] leftResult = left.join();

                    if (leftResult[0] < rightResult[0]) {
                        return leftResult;
                    }
                    else {
                        return rightResult;
                    }
                }
            
        }




    }


    @Override
    protected int[] compute() {
        throw new UnsupportedOperationException("Unimplemented method 'compute'");
    }   
}

Are there any suggestions as to what I can change or try?

I tried changing the finder value and then entering different values as the rows, columns, xmin, xmax, ymin, ymax and search density values.

Nol4635
  • 631
  • 1
  • 14
  • 24

0 Answers0