Question

Resource Allocation The representative of Health Department of Texas wants to investigate the optimal allocation of organ procurement organizations (OPOs) for organ transplant Location data Demand x oint # ???? 2 2 3 4 10 10.5 11 18 18 21 24 28.5 3 25 26 25.5 4 30 32.5 -5 2.5 6 -15 4 10 12 13 OPO2 6 OPO114 OPO1 30.5-5.5 OPO2 20.5 5.5 OP03 | 25.5 | 3.5

***The program language is Java***

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.io.*;
import java.util.*;


public class Demo241{

     public static void main(String[] args){

         double[] x = {0,9,10,10.5,11,18,18,21,24,28.5,25,26,25.5,30,32.5};
         double[] y = {0,1,8,11,-5,2.5,-7,-4,-15,3,-9,-3,4,-6,-5};

         double[] opox = {30.5,20.5,25.5};
         double[] opoy = {-5.5,-5.5,3.5};
         int[] assign = new int[15];
         Scanner sc = new Scanner(System.in);
         int n = -1;
         int invalidcount = 0;
         while(true){
             System.out.print("Choose an allocation rule: 1- nearest rule, or 2 - farthest rule:");
             n = Integer.parseInt(sc.nextLine());
             if (n != 1 && n != 2){
                invalidcount++;
                System.out.println("Invalid choice\n");
                if (invalidcount == 3){
                   System.out.println("Terminating.....");
                   return;
                }
             }
             else {
                 break;
             }
          
         }
         System.out.print("Allocation Results: [");
         if (n == 1){
            for (int i = 0; i<15; i++){
                double min = 1000;
                int mini = 0;
                for (int j = 0; j<3; j++){
                    double d = Math.sqrt((x[i] - opox[j]) * (x[i] - opox[j]) + (y[i] - opoy[j]) * (y[i] - opoy[j]));
                    if (d < min){
                       min = d;
                       mini = j;
                    }
                }
                assign[i] = mini + 1;
           
                if (i < 14)
                   System.out.print(assign[i] + ",");
                else
                   System.out.print(assign[i] );
            }
         }
         if (n == 2){
            for (int i = 0; i<15; i++){
                double max = 0;
                int maxi = 0;
                for (int j = 0; j<3; j++){
                    double d = Math.sqrt((x[i] - opox[j]) * (x[i] - opox[j]) + (y[i] - opoy[j]) * (y[i] - opoy[j]));
                    if (d > max){
                       max = d;
                       maxi = j;
                    }
                }
                assign[i] = maxi + 1;
           
                if (i < 14)
                   System.out.print(assign[i] + ",");
                else
                   System.out.print(assign[i] );
             }
         }
         System.out.println("]");
        
     }
}

/*


Q2 :

OPO1 can cover only 50 miles


The modification will be as follows:

1. The for loop will be modified. Here we are calculating the distance between the demand point and the OPO center. We need to place a check there
   that if the distance is more than 50 miles from OPO1 , then OPO1 will not be considered for neares and farthest consideration for this demand point.

   The code modification is as follows: (Shown for nearest calculation but it will be same for the relevant for code for the farthest calculation

            for (int i = 0; i<15; i++){
                double min = 1000;
                int mini = 0;
                for (int j = 0; j<3; j++){
                    double d = Math.sqrt((x[i] - opox[j]) * (x[i] - opox[j]) + (y[i] - opoy[j]) * (y[i] - opoy[j]));
                    if ( j == 0 && d > 50){
                        continue;
                    }
                    if (d < min){
                       min = d;
                       mini = j;
                    }
                }
                assign[i] = mini + 1;
           
                if (i < 14)
                   System.out.print(assign[i] + ",");
                else
                   System.out.print(assign[i] );
           }

Q3.

OPO2 can cover demand points in the north of it.

1. The for loop will be modified. Here we are calculating the distance between the demand point and the OPO center. We need to place a check there
   that if the y coordinate of the demand point is less than the y-coordinate of OPO2 , then OPO2 will not be considered for neares and farthest consideration for this    demand point.

   The code modification is as follows: (Shown for nearest calculation but it will be same for the relevant for code for the farthest calculation)
            for (int i = 0; i<15; i++){
                double min = 1000;
                int mini = 0;
                for (int j = 0; j<3; j++){
                    if ( j == 1 && y[i] <= opoy[j]){
                        continue;
                    }
                    double d = Math.sqrt((x[i] - opox[j]) * (x[i] - opox[j]) + (y[i] - opoy[j]) * (y[i] - opoy[j]));
                    if (d < min){
                       min = d;
                       mini = j;
                    }
                }
                assign[i] = mini + 1;
           
                if (i < 14)
                   System.out.print(assign[i] + ",");
                else
                   System.out.print(assign[i] );
           }


Q4.

Total demand points covered should not exceed 10.

1. The for loop will be modified. So in this case we will run the loop for only upto 10 as only 10 demand points can be considered with all OPOs
   The modifed code is as follows: (Shown for nearest calculation but it will be same for the relevant for code for the farthest calculation)

           
            for (int i = 0; i<10; i++){
                double min = 1000;
                int mini = 0;
                for (int j = 0; j<3; j++){
                    double d = Math.sqrt((x[i] - opox[j]) * (x[i] - opox[j]) + (y[i] - opoy[j]) * (y[i] - opoy[j]));
                    if ( j == 1 && y[i] <= opoy[j]){
                        continue;
                    }
                    if (d < min){
                       min = d;
                       mini = j;
                    }
                }
                assign[i] = mini + 1;
           
                if (i < 14)
                   System.out.print(assign[i] + ",");
                else
                   System.out.print(assign[i] );
           }

  

*/

Add a comment
Know the answer?
Add Answer to:
***The program language is Java*** Resource Allocation The representative of Health Department of Texas wants to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose OPO 1 can cover demand points only within 50 miles. Explain in 10 sentences (or...

    Suppose OPO 1 can cover demand points only within 50 miles. Explain in 10 sentences (or less) how to modify your program code. Resource Allocation The representative of Health Department of Texas wants to investigate the optimal allocation of organ procurement organizations (OPOs) for organ transplant Location data Demand x t# ???? 10.5 11 18 18 24 28.5 3 26 25.5 4 32.5 -5 9 2.5 5 12 13 oPo1 14 OPO1 30.5 5.5 OPO2 20.5 -5.5 | ???? 125...

  • This is a MATLAB question need details step by step Class15_voltage.txt 2070.106649    1959.461152 1854.729565 1755.595796...

    This is a MATLAB question need details step by step Class15_voltage.txt 2070.106649    1959.461152 1854.729565 1755.595796 1661.760645 1572.940905 1488.868508 1409.289711 1333.964335 1262.665039 1195.176631 1131.295423 1070.828614 1013.593705 959.4179554 908.137855 859.5986337 813.6537939 770.1646679 729 690.0355497 653.1537172 618.2431883 585.1985985 553.9202148 524.313635 496.2895026 469.7632369 444.6547784 420.8883462 398.3922104 377.0984745 356.9428712 337.8645684 319.8059851 302.7126183 286.5328779 271.2179313 256.721556 243 230.0118499 217.7179057 206.0810628 195.0661995 184.6400716 174.7712117 165.4298342 156.5877456 148.2182595 140.2961154 132.7974035 125.6994915 118.9809571 112.6215228 106.601995 100.9042061 95.5109593 90.4059771 85.57385199 81 76.67061663 72.57263525 68.69368759 65.0220665 61.54669054 58.25707056 55.14327806 52.19591521...

  • Data Analysis is designed to build a strong foundation for development of statistical literacy and statistical...

    Data Analysis is designed to build a strong foundation for development of statistical literacy and statistical thinking. Both are essential for business success and further studies in business. Recent research showed that “On average for 15-year-old Australian students, females achieved at a significantly lower level than male students (in mathematics)” (p.2, Buckley 2016) 1 . However, there is also research evidence that “Despite the stereotype that boys do better in math and science, girls have made higher grades than boys...

  • Please Show all work . Use attached Data and graph to answer questions Titration of Acetic...

    Please Show all work . Use attached Data and graph to answer questions Titration of Acetic Acid: 0. IM 1) Check to make sure that the volume on If it does not read 0.00 mL, adjust it to do so before you proceed any further. your sodium hydroxide buret reads 0.00 mL 2) Use the buret that is located near the acetic acid container to dispense 25.00 mL of acetic acid solution into a clean dry 100 mL beaker. Record...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT