2018 MCM/ICM Summary Sheet
2018 MCM/ICM Summary Sheet
2018 MCM/ICM Summary Sheet
型
2018 MCM/ICM Summary Sheet
(Attach a copy of this page to each copy of your solution paper.)
Our team is asked to build an assessing and construction system for the growing
模
electric charging network. The model is related to several factors ranging from economic
levels to consumer psychology. Among all these factors, we choose GDP per capita,
vehicle density and population density as the key components of the main evaluation
学
indexes. In addition, we also apply our model to the real situation, such as the network
in the U.S, South Korea and other countries. Besides, we also take the influences of other
quantifiable factors and non-quantifiable factors into consideration and give the analysis.
数
The first thing we do is to quantify the key factors’ influences on the charging net-
work.We redefine the concept of urban, suburban and rural areas. And we establish a
functional relationship between the charger density and our chosen factors. Then we
:
use the method of K-Means Clustering to determine the chargers’ optimal location in
different areas. Furthermore, taking the U.S and South Korea as example, we give out
the amount of charging stations in different areas. Considering the actual situation, we
号
charging station is only related to the probability of the total flow of the node and has
no relevance with the output of the node, which is the basis of our model. Then we give
the recommended site position in Seoul. We also analyze how a country should invest
公
charging stations in the next following years. We give the quantified relationship between
time, the ownership of electric vehicles and other vital factors. By applying the model to
South Korea, we give the time it will take for electric vehicles to reach different percentage
微
更多数模资讯和学习资料,请关注b站/公众号:数学建模BOOM
b站主页:https://space.bilibili.com/350975620
Team # 82504 Page 1 of 25
Contents
1 Introduction 2
1.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
型
3.2 Charging Network in Urban and Suburban Areas . . . . . . . . . . 4
3.3 Charging Network in Rural Areas . . . . . . . . . . . . . . . . . . . 7
模
3.4 Distribution of Charging Stations . . . . . . . . . . . . . . . . . . . . 7
学
4.1 Switch to All-electric in South Korea . . . . . . . . . . . . . . . . . . 8
4.2 A proposal for evolving South Korea from zero chargers to a full
electric-vehicle system . . . . . . . . . . . . . . . . . . . .
数 . . . . . . 12
4.3 Timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.1 Strengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7.2 Weaknesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.3 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
信
Reference 21
B Matlab Codes 23
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 2 of 25
1 Introduction
型
Motivated by demands of the environment and economy, there are increasing
interests in the development of electric vehicles. The network of charging stations
for electric vehicles will have a great impact on the expansion of electric vehicles.
模
There exist several factors such as vehicle density, economic level, population
density influencing the site selection of electric stations. Based on the official data
offered by Tesla and governments, we will:
学
• Build several models as to deliver construction plans under diverse situa-
数
tions.
• Determine the total number of electric vehicles and major influencing fac-
:
tors if the country replaces all the traditional vehicles with electric vehicles.
• Deliver a handout including suggestions for different nations and key fac-
众
tors.
公
ing network. It’s based on the shortest distance, drivers’ anxiety range and the
assumption that every driver only charges no more than once per day. The input
data source can be generated randomly.[1]
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 3 of 25
2.1 Assumptions
1. (Shortest-path) Each vehicle go to the station with the shortest distance to get
charged.
型
3. Only public charging stations are considered in this essay.
模
2.2 Notations
学
The primary notations used in this paper are listed in the table below.
Table 1: Notations
数
Symbol Definition
x(i) sample point in K-Means clustering
:
µc(i) the cluster centroid to which x(i) is assigned
ru the maximum radius of capturing areas of urban stations
rs the maximum radius of capturing areas of suburban stations
号
ρ density of population
Ḡ GDP per capita
cu a constant used in calculating ru
公
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 4 of 25
In recent years, Tesla has built more than 2500 charging stations around the
United States, which is a quite impressive number. From the official system called
Find Us[2], it is obvious that there have been Tesla’s charging stations along most
of the big cities and main expressways in the United States, even in Alaska and
Hawaii.
型
Apparently, although, there are still many areas not covered by built charging
stations, the number of charging stations has exceeded 1% of the number of gas
stations, which is smaller than 200 thousand[3]. While the total number of sold
模
Tesla is only around 300 thousand[4], which is only around 0.1% of the number
of cars[5]. Tesla is building charging stations much more than it is supposed to
build, which reflects its long-term plan of developing electric vehicles.
学
Furthermore, Tesla is generally known and accepted by more people. It is
also investing more and more in construction of charging stations, research and
数
technical development. Although electric cars can still not complete long distance
travel because of the limit of battery, superchargers can partly solve this problem
:
if a complete charging network is completed. Except those who need to drive
long distance at a daily frequency, which are only a small part of drivers, most
people’s daily need for vehicles can be satisfied by existing technology provided
号
by Tesla.
Certainly, it is not an easy task to replace millions of vehicles on the road, but
众
Tesla is on the right track, and we have strong confidence that Tesla can complete
the switch to all-electric in the U.S.
公
In big cities like New York or Los Angles, we need many charging station-
s to garuantee that electric vehicle drivers can get their cars charged whenever
微
their cars are lack of power. Therefore, considering the cost of building charging
stations, the proper number and distribution of the charging stations become an
essential problem.
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 5 of 25
least 5% power, which can protect the battery from the damage of too little power
left. Based on the data given in the official website[6], most Tesla cars can cover
around 300 miles with a charge. Thus we set the maximum radius of the cap-
turing area of a charging station is 15 miles. However, 15 miles is not a distance
easy to cover in the complex urban traffic. Considering the negative correlation
between r and the economical condition, density of people and average number
of vehicle per capita, we can calculate r more accurately by
cu
ru = 1 (1)
(ρv Ḡ) 4
cs
rs = (2)
型
1
(ρv Ḡ) 4
rs , ru ≤ 15 miles
模
where cu , cs are constants unrelated with areas. In practice, we use the completed
charging network in Manhattan to estimate cu , and cs is calculated by cu and the
ratio of urban size and suburban size, urban residents and suburban residents.
学
Without loss of generality, we can divide the urban area to several squares,
and consider the distribution of stations in each square. Empirically, we think
数
the shape of capturing area is close to a square when the cars in the urban and
suburban areas are evenly distributed, which is evidenced by using advanced
K-Means clustering algorithm. Thus, the estimation of the optimal number of
:
charging stations in a square with length of 40 miles can be estimated by
402
号
n0 = d e (3)
r2
where r is defined by the above equation.
众
公
信
微
获取更多资讯
Team # 82504 Page 6 of 25
areas, we can also use K-Means in choosing the optimal locations of the charging
stations after some original improvements.
型
n
X
tortion function[7] J(c, µ) = kx(i) − µc(i) k22 , while our algorithm’s distortion
i=1
模
function is defined as
J(c, µ) = maxi kx(i) − µc(i) k∞ (5)
学
By the above improvements of K-Means clustering, we can regard the cen-
troids generated by our algorithm as the optimal placements of charging stations,
数
since our definition of distance and distortion function can garuantee that the car
can always find the nearest station within r miles if J(c, µ) < r.
:
Below is an example of capturing areas and optimal placement of charging
stations chosen by K-Means clustering.
号
众
公
信
微
获取更多资讯
Team # 82504 Page 7 of 25
The U.S. Department of Health and Human Service defines the word rural as
encompassing "...all population, housing, and territory not included within an
urban area. Whatever is not urban is considered rural. "[8] Thus, we can divide
the rural areas which need charging stations construction to two parts: villages
and public roads.
In most cases, the radius of a village will be smaller than 4 miles, so there
needs to be only one charging stations in a village.
型
When considering the charging stations on public roads, since there will be no
gas station if everyone switched to all-electric personal passenger vehicles, an im-
portant function of charging stations is to offer a place to rest for drivers. Besides,
模
there will be congestion in charging stations if everyone needs to charge in the
same charging station. Therefore, we need to construct stations at relatively high
frequency. Compared to the distribution of gas stations, considering the longer
学
time of charging, constructing a charging station every 20 miles is an acceptable
frequency.
Therefore, we have
数
l
nr = nv + d e (6)
20
:
In practice, since the difference between town, county and village are not very
clear, we regard the cities with population fewer than 10,000 as villages[9].
号
众
Based on the above discussions, the number of charging stations needed can
公
be calculated by
Su Ss l
信
n = nu + ns + nr = d 2
e + d 2 e + nv + d e (7)
ru rs 20
To make it more accurately, we calculate it state by state, and here are the results.
微
获取更多资讯
Team # 82504 Page 8 of 25
electric vehicles power to keep going in a short time, so most chargers located
on expressways should be superchargers. In contrast, chargers in urban and sub-
urban area or villages are mostly used by residents or residents, thus we can
put more destination charging in these stations. Based on this analysis, we rec-
ommend 90% of the chargers in the stations located on expressways should be
superchargers, and 70% of the chargers in the stations located in urban, suburban
areas or villages should be destination charging.
型
Based on the first task, we set some more indexes to assess the amount of
charging stations, their locations and other details.
模
4.1 Switch to All-electric in South Korea
学
Korea is one of the typical country in the world which have the ability to
数
complete the plan of replacing motor vehicles with electric cars.
:
4.1.1 Amount of Two Types of Charging Stations
号
First, We divide South Korea into three parts of rural cities and suburbs based
众
on the population density in Korea. According to the table, we classify Seoul, Bu-
1000-4000 Suburb
0-1000 Rural
微
Next, we conduct cluster analysis of different areas and quantify the influence
of population density on charger density. Meanwhile, the GDP data and popula-
tion data will also have an impact on the amount of charging stations. For data
obtained, we use direct least square fitting method and conclude the simulation
results.
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 9 of 25
型
模
学
数
:
Figure 3: Verification of the fitting results
号
Then, we substitute the conclusion into the equations listed in task1 and con-
clude that the capturing radius for destination chargers in South Korea is The
众
Rural 15
微
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 10 of 25
型
模
学
数
:
Figure 4: The relationship between capturing radius and charging station density
号
Supercharging Stations
众
rest time, which is what we think the most important factor when designing the
network. Therefore, we set the distance between two charging station on nation-
al highway to about 20-50km, 50-170km for other roads. Finally, by calculation
信
based on the road length and the coverage area of road network,we reach the
total num of supercharging station.
微
We use two methods to select the site for stations and compare them with each
other. For displaying our work clearer, we will only show the detailed results of
Seoul.
Markov method
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 11 of 25
First, we assume that the flow rate controlled by the charging station is only
related to the probability of the total flow of the node, which has no relevance
with the output of the node.
型
0
a+b a+b
Obviously, this matrix is an irreducible matrix.
模
Then, we analysis the matrix after limitless steps. Conducting spectral decom-
position on the matrix, we get the characteristic root of it.
学
x1 = 1 (8)
r
8abc
−1 + 1−
数
(a + b)(a + c)(b + c)
x2 = (9)
2
:
r
8abc
−1 − 1 −
(a + b)(a + c)(b + c)
x3 = (10)
2
号
Define matrix D as
x1 0 0
0 x2 0
众
0 0 x3
1 1
We can also get the transition matrix T by calculating. Defind K = Diag( , ,
公
3 3
1
). Therefore, the final situation is available.Every element in KT −1 D∞ T wil gets
3
信
larger as its proportion rate increases. When two rates equal, their corresponding
elements equal.
微
When the num of nodes comes to 4, we might as well assume the four edges’
weights as 1, 3, 2, 2. Then its Markov transition matrix is
0 0.33333333 0 0.66666667
0.25000000 0 0.75000000 0
0 0.60000000 0 0.400000000
0.50000000 0 0.50000000 0
Its ergodic state is
0.18749998 0.24999998 0.31249997 0.24999998
Based on the calculation results, we can reach the conclusion that even if each
in-degree edge’s weight is different, the final distribution represents the same
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 12 of 25
results. For any diagram, we can block it to several small pieces and apply our
method to it.
Thus, our assumption is verified. The flow chart in the actual situation is
型
end while
end for
模
SFCLM method
学
In the relate work of the article, we made a brief introduction of SFCLM. When
it comes to the verification, we apply Seoul road data into it and get a comparable
solution. 数
Using these two methods, we draw the picture of charger network we recom-
mend for Seoul. As in the pictures shown below, the distribution is similar to
:
each other, verifying our model’s reliability.
号
众
公
信
获取更多资讯
Team # 82504 Page 13 of 25
s. Building all-city based chargers will dispel potential customers’ worries as well
as play the role of propaganda.
As Ona Egbue and Suzanna Long stated in their article, "Consumer accep-
tance is important as it is key to the commercial success (or failure) of EVs[10]" .
The construction of charging station should aim at arousing the customers’ inter-
ests. Considering customers’ worries, in the early construction, we recommend
building chargers first to attract customers. We define this period as ’extension
period’. After the user of electric vehicle reaches a certain ratio of all the users,
the speed of construction can slow down. In this ’stationary period’, the con-
struction has less relevance with the car purchases, but the population density or
other possible factors. As construction continues, the charging stations tend to
型
saturate. To avoid the waste of resources, we need to aim at customers’ needs. In
this ’mature period’, we suggest building chargers in response to car purchases.
模
The key factors that shaped our proposed charging station plan includes pop-
ulation density, GDP per capita and vehicle density, which have something to do
学
with purchase desire.
4.3 Timeline
数
:
To calculate the number and the distribution of charging station.We establish
a model of logistic model.
号
The high market proportion of Tesla in a region tends to have positive feed-
back on the local Tesla ownership.Therefore, we have
众
dR
= kR (11)
dt
Since the ratio can’t reach 1, we can change our model to
公
dR
= kR(1 − R) (12)
dt
信
R= (13)
1 + Cekt
In 2018, the market proportion of Tesla cars is estimated about 1%.Then we con-
clude that C=0.01. New technology tends to spread the fastest in urban areas,
then in suburban areas, the slowest in rural areas.Besides, the amount of Tesla
cars in an area has a strong connection with the economic level.If we set k in
urban areas equaling to 0.3, in suburban areas equaling to 0.26, in rural areas
equaling to 0.22.
Based on our model, we estimate that by the end of 2026, 10% motor vehicles
in South Korea will be driven by pure electricity, 30% by the end of 2031, 50%
by the end of 2034, and 90% by the end of 2042. We can also conclude from
the simulation results that in the recent years, the increasing rate will reach its
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 14 of 25
maximum. In 2035, the increasing rate in suburban areas will catch up with that
in urban areas. In 2038, the increasing rate in rural areas will catch up with that
in suburban areas.
Here are the visualized simulation results of the variation trend of Tesla’s mar-
ket share and its increasing rate.
型
模
学
Figure 7: Variation Trend of Market Share Figure 8: The Incresing Rate of Tesla
数
Based on the car ownership data provided by Statistics Korea[11], we build
the growth model of motor vehicles in South Korea.
:
dy
= 2.2 × 10 − 0.4 × (5000 − y) (14)
dt
号
The current population of South Korea is fifty million. The ownership of vehicles
will gradually saturate while approaching the population. At the present stage,
众
Figure 9: Electric vehicle density by province in South Korea in 2026, 2031, 2034, 2042
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 15 of 25
型
Nowadays, there are more than 200 countries in the world. Different countries
have different geometrical, economical, political and cultural differences, which
模
will all impact the promotion of electric vehicles. Next, we will present our clas-
sification pattern and growth model for some typical types of countries.
学
5.1 Classification of Countries 数
In short, GDP per capita and density of population are two essential factors
in this classification model because GDP per capita can reflect the purchasing
:
ability, which will influence the switch speed, and denity of population can reflect
geometrical features of the country, which will influce the construction process of
charging stations.
号
In practice, we divide both the GDP per capita and density of population[12]
to three degrees named low, medium and high. For the country with low degree
of GDP per capita, we do not recommend them migrate to electric cars at present
信
As for the countries larger than 1000 square mile whose Gini coefficient is
higher than 0.6, we think them have problems of imbalanced regional develop-
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 16 of 25
ment, which make the above classification model not suitable. In this condition,
we will seperate them to several parts with each part having more similar back-
ground, then we can regard these parts as "small countries", classify them to d-
ifferent types defined in the above model and apply different growth models to
them.
Take China as example. In our classification, China has medium GDP per
capita and high density of population. However, in eastern provinces like Zhe-
jiang, the GDP per capita is higher than 10000 USD and the density of population
is higher than 1000/mi2 , which meet the standards of countries with high GDP
per capita and high density of population. Meanwhile, Tibet’s condition is totally
different. With density of population of 1000/mi2 and GDP per capita of 4500
型
USD, it should be regarded as medium GDP per capita and low density of pop-
ulation. Obviously, applying different growth models to them is a more reliable
模
choice.
学
5.2 Assessment of Feasibility
capita and vehicle density. For some certain reasons like political restriction, some
countries like Russian or Singapore is against the conclusion. This situation is not
众
5.2.2 Geography
Arabia, China and Australia. Intuitively, we can see that the stations are much
denser along coastal areas and the most economically developed areas. There are
微
two reasons resulting in the situation. On the one hand, these areas are opener
to the outer world and new technology. On the other hand, the GDP per capita
in these areas are higher, so there exist more potential customers with stronger
purchasing ability than other areas.
获取更多资讯
Team # 82504 Page 17 of 25
However, to migrate to electric vehicles completely, it’s far from enough to just
set charging stations in these areas. To determine whether an area is qualified to
construct charging network, we set some indexes to quantify it.
• Profit function: φ(x) = ax + e. a means the profit per vehicle. x means the
number of electric vehicles. e means the network construction fee which the
area can afford.
型
of charging stations. c equals to price × (p − station_num_at_present). k is
in proportion to the increasing rate of electric vehicles in the area/country.
In the beginning, the amount of charging stations is nearly in proportion
模
to the num of electric vehicles. When traditional vehicles no longer exist,
the needs for charging will always be satisfied no matter how the num of
学
electric vehicles changes. The cost will be a relatively number.
We verify the model by applying several countries’ data into it. For example,
众
China is able to conduct the construction while Indonesia is not. The results of
other countries also match the reality.
公
6.1 Batteries
微
On the one hand, the battery capacity determines electric vehicles’ maximum
distance once charged, which is the major basis for capturing area defined in our
model, as to change the network.
获取更多资讯
Team # 82504 Page 18 of 25
can be replaced easily, the number of people who use charging station is sure
to decrease sharply, which will also influence the capturing area defined in our
model, further changing the network, or even replacing all the charging stations.
型
tion process, designers must take installation costs into account. The high costs of
charging station are against the expansion of charging stations, further slowing
down the replacement of traditional vehicles. With the development of the man-
模
ufacturing technology of charging piles, network designers are able to no more
considerate these social restrictions and adapt the network to a more optimized
学
one. In our model, these changes will reflect on the percentage of electric vehicles
among all the vehicles, which can also be quantified and are similar to the results
in task 2a. 数
6.3 Types of Vehicles
:
From the present perspective, replacing traditional vehicles with electric ones
号
is the best choice for human development. However, vehicles change rapidly.
Electricity has never been the only choice. In the near future, vehicles driven by
other energy or hybrids may attract customers’ interests. Charging stations will
众
face fiercer competition and increasing requirements. Other factors, such as the
convenient access, energy types or quality, may play a more important role in
network planning. Under this situation, we plan to add more influence factors to
公
the evaluation index in our model, as to understand the demands more precisely.
信
Our model takes economic level, population density, vehicle density, regional
differences into consideration when forming the model. Based on the modeling
process, we make some comments on our model as listed below.
7.1 Strengths
Reliablity: The factors we choose to form the evaluation system are typical,
which perform well in real testings. The data sources include authorities and
several national statistical agencies, ensuring the data quality. Besides, during
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 19 of 25
the process of modeling, we try to quantify the indexes as far as possible, which
avoid the interference originating from the researchersâĂŹ individual social ten-
dencies, thus strengthening the reliability.
Extensibility: Every test index used is relatively independent. Therefore, it’s easy
to adapt test indexes to different testing situations. Since all the indexes used in
our model are easily available, we can extend our model to multiple types of
countries with various background without many adjustments.
Universality: Our model uses the formula(1)(2) to describe the relationship be-
tween the vehicle density and the density of the station, which is universal. It
has high universality for different population density in different areas. For the
型
growth mode of Tesla electric vehicle, we adopt the logistic growth model, which
reflects the development trend of Tesla EV in the future decades. It can be ref-
erences for the government’s decisions. When it comes to the site selection, we
模
use Markov chain model and SFCLM model. The former is convenient and easy
to operate, and the latter has precise characteristics. Both have a complementary
学
role in the construction of government investment. At the same time, our model
has made a specific classification for different types of countries, and predicted
the construction of the Tesla charging station in Korea.
数
7.2 Weaknesses
:
tain and varies from regions, and it is nearly impossible to estimate when we are
dealing with the model designed for many countries. Thus, we haven’t taken the
factor into consideration of our general model. If we need to build a charging
众
station distribution model for a certain region, then it would be quite easier to
introduce the influence of construction fee to our model.
公
Data Limitation: Because of the limit of data availability, we are not able to
predict exactly where is unsuitable for construction. At the same time, we do
not consider political factors and other non-quantified indexes so that the model
信
may not be applied in some special countries where there are political or regional
constraints on electric vehicles. Meanwhile, since Tesla is the latest technology,
微
we may not consider the effect of alternative factors like other power resources
which can replace electricity.
获取更多资讯
Team # 82504 Page 20 of 25
It’s a great honor for us to present you our research results of the migration
towards electric vehicles. We sincerely hope that it will provide some references
for you while making policies and plans. We also hope our suggestions could
play a part in the development of electric vehicles and the betterment of human
development. In the next part of the handout, we will describe our modeling
concepts and advice to you in detail.
型
The key factors of our model include: economic level, user density and de-
velopment potential, which can be quantified precisely. Other factors include
geographies, consumer psychology or other factors that are hard to quantify. The
模
components and functions are listed in our article in detail. You can refer to them
while formulating policies.
学
In our assessing system, there are four steps to design the charging network.
First, use the assessing function to determine whether the economic level in your
数
country or area is enough to sustain the cost of construction. The function has
been verified to be effective.
:
Next, calculate the number of charging stations in different areas. By using
the functions we provide, you can get the suggested charging station density in
different areas. Some special situations, such as stations on the highway are also
号
Then, determine the exact position. Based on the Markov method, you can
众
determine the relationship between the charger station and the road network.
Finally, add other functions to the network. Besides the indxes and functions we
provide, you can also add national characteristic data to the assessing system.
公
The construction and usage of private chargers may affect the network in the
future.
信
By using the methods we provide, you can also estimate the exact time when
electric vehicles is in certain proportion to traditional vehicles. According to the
timetable, a gas vehicle-ban date can be decided scientifically.
微
Your sincerely,
#82504
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 21 of 25
References
型
[4] Tesla Sales: https://en.wikipedia.org/wiki/Tesla,_Inc.#Production_and_sales
模
of-vehicles-in-the-united-states-since-1990/
学
Tesla Model X: https://www.tesla.com/model-x
Tesla Model 3: https://www.tesla.com/model3
数
[7] K-Means clustering: http://cs229.stanford.edu/notes/cs229-notes7a.pdf
https://www.statista.com/statistics/241695/number-of-us-cities-towns-
villages-by-population-size/
[11] http://kostat.go.kr/portal/eng/index.action
公
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 22 of 25
def kmeans(data,k=2):
def _euclidDistance(p1,p2):
return np.sqrt(np.sum((p1-p2)**2))
def _manhattanDistance(p1,p2):
return np.sum(np.abs(p1-p2))
型
def _randCenter(data,k):
n = data.shape[1] # features
centroids = np.zeros((k,n)) # init with (0,0)....
模
for i in range(n):
dmin, dmax = np.min(data[:,i]), np.max(data[:,i])
centroids[:,i] = dmin + (dmax - dmin) * np.random.rand(k)
学
return centroids
old_centroids = np.copy(centroids)
for i in range(n):
# determine the nearest centroid and track it with label
公
# update centroid
for m in range(k):
if data[label==m].size!=0:
centroids[m] = np.mean(data[label==m],axis=0)
converged = _converged(old_centroids,centroids)
return centroids, label, np.max(assement)
data = np.random.uniform(0,30,(10000,2))
best_assement = np.inf
best_centroids = None
best_label = None
max_r=15
k=25
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 23 of 25
for i in range(10):
centroids, label, assement = kmeans(data,k)
if assement < best_assement:
best_assement = assement
best_centroids = centroids
best_label = label
print (best_assement)
data0 = data[best_label==0]
data1 = data[best_label==1]
data2 = data[best_label==2]
fig, ax2 = plt.subplots(figsize=(12,12))
型
for i in range(k):
ax2.scatter(data[best_label==i][:,0],data[best_label==i][:,1])
ax2.scatter(best_centroids[:,0],best_centroids[:,1],
模
c=’b’,s=120,marker=’o’)
plt.show()
学
B Matlab Codes
数
function y = logisticmodel(year,type)
:
if type==1;
y = (0.01*exp(0.3*(year-2017)))/(1+(0.01*exp(0.3*(year-2017))));
end
if type==2;
号
y = (0.01*exp(0.26*(year-2017)))/(1+(0.01*exp(0.26*(year-2017))));
end
if type==3;
众
y = (0.01*exp(0.22*(year-2017)))/(1+(0.01*exp(0.22*(year-2017))));
end
end
公
function y = KoreaTesla(year)
y = 0.7 *logisticmodel(year,1) + 0.2*logisticmodel(year,2)
+ 0.1*logisticmodel(year,3);
信
newtxt = {};
newtxt(1,1) = txt(1,1);
newtxt(2,1) = mat2cell(0.1);
newtxt(3,1) = mat2cell(0.3);
newtxt(4,1) = mat2cell(0.5);
newtxt(5,1) = mat2cell(0.9);
for i=2:length(txt)
newtxt{i,1} = txt{i,1};
if strcmp(txt{3,5},’urban’)
newtxt{i,2} = logisticmodel(divSolution(0.1),1) * txt{i,4}
* 2246 /2237 *1600/10000;
newtxt{i,3} = logisticmodel(divSolution(0.3),1) * txt{i,4}
* 2250 /2237*1600/10000;
newtxt{i,4} = logisticmodel(divSolution(0.5),1) * txt{i,4}
* 2253 /2237*1600/10000;
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 24 of 25
型
newtxt{i,2} = logisticmodel(divSolution(0.1),3) * txt{i,4}
* 2246 /2237*1600/10000;
newtxt{i,3} = logisticmodel(divSolution(0.3),3) * txt{i,4}
模
* 2250 /2237*1600/10000;
newtxt{i,4} = logisticmodel(divSolution(0.5),3) * txt{i,4}
* 2253 /2237*1600/10000;
学
newtxt{i,5} = logisticmodel(divSolution(0.9),3) * txt{i,4}
* 2276 /2237*1600/10000;
end;
end
数
initial = 0.01;
r1 = 0.3;%urban
:
r2 = 0.26;%suburb
r3 = 0.22;%rur
year = linspace(2017,2067,200);
号
(1 + (initial * exp(r2*(year-2017))));
rur = (initial * exp(r3*(year-2017)))./
(1 + (initial * exp(r3*(year-2017))));
公
plot(year,urban,’r-’,year,suburb,’b-’,year,rur,’g-’);
legend(’urban’,’suburb’,’rural’);
grid on;
信
year(1:199),diff(rur),’g-’);legend(’urban’,’suburb’,’rural’);
grid on;
title(’the acceleration of tesla rate among all car’);
xlabel(’year’);
load(’data.mat’);
num = cell2mat(data(2:52,2:7));
X = num(:,2:4);
Y = num(:,5);
beta = inv(X’*X)*X’*Y;
function y = divSolution(num)
y0 = 2017;
y2 = 2067;
2
关注数学模型
MATHmodels
获取更多资讯
Team # 82504 Page 25 of 25
load(’data.mat’);
X = cell2mat(data(2:length(data),3:5));
型
Y = cell2mat(data(2:length(data),6));
beta = inv(X’*X)*X’*Y;
state = 2:length(data);
模
plot(state,Y,state,X*beta);legend(’charging station’,’fitted value’);
xlabel(’state’);
ylabel(’number’);
学
grid on;
数
:
号
众
公
信
微
2
关注数学模型
MATHmodels
获取更多资讯