Question

Please, answer everything in excel formulas!!!!

0 Locate 4 warehouses optimally in the United States. Which states are they in? 4 Input Data Lat Shipments Dist to W1 Dist to W2 Dist to W3 Dist to W4 Dist to picked Warehouse 15 Long 40.7 42.3 6 New York 7 Boston 8 Philadelphia 9 Charlotte 10 Atlanta 11 New Orleans 12 Miami 13 Dallas 14 Houston 15 Chicago 16 Detroit 17 Cleveland 73.9 71 75.1 80.8 84.4 89.9 80.2 96.8 95.4 87.7 83.1 81.7 86.1 39.8 104.9 93.3 33.5 112.1 40.8 111.9 34.1 118.4 37.8 122.6 32.8 117.1 41.6 122.4 10 35.2 33.8 30 25.8 32.8 29.8 41.8 42.4 41.5 39.8 13 10 12 14 18 Indy 19 Denver 20 Minneapolis 21 Phoenix 22 Salt Lake City 23 LA 24 SF 25 SD 26 Seattle 45 9 10 18 28 Decision Variables 29 Warehourse Lat 30 31 Long State 35 Constraints: Warehouses must be in USA 36 1. Lattitude: between 20 and 50 37 2. Longitude: between 60 and 130 38 Q1. Warehouse Location Q2. TSP

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

package assignment5_sharewithstudents;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Random;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.JFrame;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.border.EtchedBorder;

class GlobalVariables {
    public ArrayList<Fish> mFish;
    public FishTank mFishTank;

    private GlobalVariables() {
        mFish = new ArrayList<Fish>();
        mFishTank = new FishTank();
    }

    private static GlobalVariables instance;

    public static GlobalVariables getInstance() {
        if (instance == null){
            instance = new GlobalVariables();
        }
        return instance;
    }
}

class Fish implements Comparable<Fish>{
  
    int mX;
    int mY;
    int mId;
    Color mColor;
  
    public Fish(int id, int x, int y, Color color){
      
        mId = id;
        mX = x;
        mY = y;
        mColor = color;
    }
  
    public void paint(Graphics g){
      
        // Implement this function

    }
  
    public void move(){
       
        // Implement this function
      
    }

    @Override
    public int compareTo(Fish o) {
      
        // Implement this function

    }
}

class FishTick extends TimerTask{

    @Override
    public void run() {
   
        if (FishTank.mSimulateStatus){
          
            for (int x=0;x<GlobalVariables.getInstance().mFish.size();x++){
              
                Fish f = GlobalVariables.getInstance().mFish.get(x);
                f.move();
                GlobalVariables.getInstance().mFish.set(x, f);
            }
            
            GlobalVariables.getInstance().mFishTank.mDrawPanel.paint();
        }
    }
}

public class FishTank extends javax.swing.JFrame implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener{
  
    private final int mNumRows = 20;
    private final int mNumCols = 20;
    private final int mGridSz = 30;
  
    private int mSelectedFishIndex = -1;
    private boolean mDragged = false;
  
    private int mTopHeight;
         
    JToolBar mToolbar;
    JToggleButton mSimulationButton;
    DrawPanel mDrawPanel;
  
    private int mFishIndex = 0;
  
    static public boolean mSimulateStatus = false;
  
    public static void main(String[] args) {

        GlobalVariables global = GlobalVariables.getInstance();
      
        if (global == null){
            System.out.println("Cannot initialize, exiting ....");
            return;
        }
      
    }

    private JToggleButton addButton(String title){
      
        JToggleButton button = new JToggleButton(title);
        button.addItemListener(new ItemListener() {
           public void itemStateChanged(ItemEvent ev) {
               mSimulateStatus = !mSimulateStatus;
           }
        });
      
        this.mToolbar.add(button);
      
        return (button);
    }
  
    public FishTank()
    {
        JFrame guiFrame = new JFrame();

        guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        guiFrame.setTitle("MY FISH TANK");
      
        // Create a toolbar and give it an etched border.
        this.mToolbar = new JToolBar();
        this.mToolbar.setBorder(new EtchedBorder());
      
        mSimulationButton = addButton("Simulate");
        this.mToolbar.add(mSimulationButton);

        //This will center the JFrame in the middle of the screen
        guiFrame.setLocationRelativeTo(null);
  
        this.mDrawPanel = new DrawPanel(mNumRows, mNumCols, mGridSz);
      
        this.mDrawPanel.setBackground(Color.cyan);
        this.mDrawPanel.paint();
      
        guiFrame.add(mDrawPanel);
        guiFrame.add(this.mToolbar, BorderLayout.NORTH);
      
        // Add the Exit Action
        JButton button = new JButton("Quit");
        button.setToolTipText("Quit the program");
        button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
        });
        mToolbar.add(button);
    
        guiFrame.addMouseListener(this);
        guiFrame.addMouseMotionListener(this);
      
        //make sure the JFrame is visible
        guiFrame.setVisible(true);
      
        mTopHeight = guiFrame.getInsets().top + mToolbar.getHeight();
        guiFrame.setSize(mNumRows * mGridSz, mNumCols * mGridSz + mTopHeight);
      
        Timer timer = new Timer("tick", true);
        timer.scheduleAtFixedRate(new FishTick(), Calendar.getInstance().get(Calendar.MILLISECOND), 500);
    }

    @Override
    public void mouseClicked(MouseEvent e) {
      
        // Implement this function
    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
      
        // Implement this function
    }

    @Override
    public void mouseEntered(MouseEvent e) {
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }

    @Override
    public void mouseDragged(MouseEvent e) {
      
        // Implement this function
    }

    @Override
    public void mouseMoved(MouseEvent e) {
    }
}

class DrawPanel extends JPanel{

    int mRows;
    int mCols;
    int mGridSz;
    int maxGridSz;
  
    ArrayList<Fish> mFish;
  
    public DrawPanel(int numberOfRows, int numberOfCols, int gridSz){
      
        mGridSz = gridSz;
        mRows = numberOfRows;
        mCols = numberOfCols;
        maxGridSz = mGridSz * mRows;
    }
  
    private void paintBackground(Graphics g){
      
        for (int i = 1; i < mRows; i++) {
            g.drawLine(i * mGridSz, 0, i * mGridSz, maxGridSz);
        }
      
        for (int mAnimateStatus = 1; mAnimateStatus < mCols; mAnimateStatus++) {
            g.drawLine(0, mAnimateStatus * mGridSz, maxGridSz, mAnimateStatus * mGridSz);
        }
    }
  
    @Override
    public void paintComponent(Graphics g){
      
        super.paintComponent(g);
      
        paintBackground(g);
      
        for (Fish f:GlobalVariables.getInstance().mFish){
            f.paint(g);
        }
      
    }

    public void paint(){
        repaint();
    }

}

Add a comment
Know the answer?
Add Answer to:
Please, answer everything in excel formulas!!!! 0 Locate 4 warehouses optimally in the United States. Which...
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
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
ADVERTISEMENT