MATLAB Application Example (8)-fminimax

Source: Internet
Author: User

To set up a city that has a demand point for a certain item, the coordinates of the Pi for the first demand point are (ai,bi), The road network is parallel to the axis and orthogonal to each other. It is intended to establish a supply centre for the goods, and due to certain conditions in the city, the supply center can only be located in the x - sector at [5,8],y Bounded within [5.8] . Ask the center where it should be built for good ?

the coordinates of the P point are:

Ai

1

4

3

5

9

12

6

20

17

8

Bi

2

10

8

18

1

4

5

10

8

9

Solution: The location of the supply Center is (x, y)and requires it to be as small as possible to the farthest point of demand, where the distance traveled along the road (8-1) is used. , the mathematical model is:


Figure 8-1 Road Map of Supply center to demand point

Solving with the fminimax function of MATLAB

Fun011.m

function f=fun011 (x)

M=[1 4 3 5 9 12 6 20 17 8];

N=[2 10 8 18 1 4 5 10 8 9];

Str=[repmat (' (', 10,1) num2str (M ') num2str (n ') repmat (') ', 10, 1)];

Plot (m,n, ' O ')

Text (M,N,CELLSTR (str))

On

For I=1:10

F (i) =abs (x (1)-M (i)) +abs (x (2)-N (i));

e nd

Main function

Fun011yunxing.m

Clc

Tic

X0=[6;6];

A=[-1 0;1 0;0-1;0 1];

B=[-5;8;-5;8];

LB=[0;0];

Ub=[];

[X,fva,maxfval,exitflag,output]=fminimax (@fun011, X0,a,b,[],[],lb,ub)

Plot (x (1), X (2), ' R * ')

Toc

Solution to:

x =

8

8

FVA =

13 6 5 13 8 8 5 14 9 1

Maxfval =

14

Exitflag =

4

Output =

Iterations:3

Funccount:14

......

The time has gone 0.670458 seconds.

At the same time we describe the problem with figure 8-2 , and The point is the point of the calculation. And the minimum maximum supply distance from the Supply Center (8,8) to the demand point ( the distance.


Figure 8-2 Demand Point and supply center

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MATLAB Application Example (8)-fminimax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.