Question: function project _ 1 0 ( ) % PROJECT _ 1 0 project _ 1 0 ( ) is the driver function for the program.
function project
PROJECT project is the driver function for the program.
Name:
Date:
Class: CMPSC
Description: Determine the optimal location of a warehouse
Use printsplashscreen to print your splash screen
Enter the locations of the customers using a single call
to getlocations in the getlocations function you will
need to call getdata twice for each customer. You must use
getdata to error check that all locations are between
and
X X X X X Y Y Y Y Y getlocations;
Prompt the user for the customer volumes
Again you only have a single call to getvolumes in the
getvolumes function you will
need to call getdata once for each customer. You must use
getdata to error check that all volumes are greater than or
equal to
V V V V V getvolumes; Get the five volumes
Find the optimal location
Note that there ten input values to this function, three for each
customer
x y lowestcost findoptimalX X X X X Y Y Y Y Y
V V V V V;
Print results from the optimization
printresultsx y lowestcost;
end
function xopt, yopt, mincost findoptimalX X X X X Y Y Y
Y Y V V V V V
FINDOPTIMAL findoptimalxLoc yLoc, shipVolumes is function that
uses a brute force algorithm to find the optimal location of a warehouse.
The function returns three values; the optimal x and y coordinates and
the minimum cost
Name:
Date:
Class: CMPSC
Set a minimum value for the cost this should be a big number e
mincost e;
Set the starting the optimal locations make it impossible
xopt ;
yopt ;
Create two nested for loops that step through all of the possible
x y pairs
for y :
for x :
Calculate the distances and costs
You should use a getdistance function and call it five
times
and then call getcost five times. Each call will use the
distance and the volume for that customer
Calculate the total cost by summing the five costs
Now check the cost against the current mincost this is a
simple if If the new cost is less than mincost change
mincost and set xopt and yopt to the current
location x y If it is not then you do not need to do
anything
ifcost mincost
end
end
end
end solve this with ai
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
