├── static └── scenario.png ├── docs └── 水箱液位的模糊控制系统设计.pdf ├── README.md ├── src ├── main.m └── test.m └── LICENSE /static/scenario.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAKURA-CAT/water-tank/HEAD/static/scenario.png -------------------------------------------------------------------------------- /docs/水箱液位的模糊控制系统设计.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAKURA-CAT/water-tank/HEAD/docs/水箱液位的模糊控制系统设计.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # water-tank: 单水箱液位模糊控制系统设计 2 | 3 | 《基于Matlab的单水箱液位的模糊控制系统设计》是本人的一次课堂作业,由于网上的资源不是很多,所以这边分享一个我对我们的"祖传代码"稍加修改的版本。 4 | 5 | ## 1. 情景说明 6 | 7 | ![scenario](./static/scenario.png) 8 | 9 | 如上图所示,有一个倒锥形容器盛放水,有一个出水口`V_2`,一个入水口`V_1`,现在可以通过测量装置得到当前容器中的水位`h`,现在需要设计一个模糊控制系统,使得水位`h`能够稳定在某个目标值。 10 | 11 | 因此有如下关系: 12 | 13 | * 控制目标:倒锥形容器的液位高度h=h0 14 | * 检测装置:通过测量容器底部压力来间接测量液位 15 | * 执行机构:控制进水电磁阀V1的开启度([0,90°])。 16 | * 为简单起见,假设电磁阀V1的开启度与进水量间呈线性关系(即上水箱的液位恒定)。 17 | * 注意:受控对象是倒锥形容器,其液位高度h和进水量Q间的关系不是线性关系。电磁阀V2的开度固定,但出水量与倒锥形容器的液位高度成正比。 18 | 19 | ## 2. 仓库说明 20 | 21 | > 本仓库只供学习使用,并且因为本人也比较🥦,所以有不妥之处欢迎指正~ 22 | 23 | 一般情况下,如果要“抄作业”,应该先跑代码(校验一下可行性,一般情况下应该跑得通),然后再看笔者与小组成员上交的文档,这样可以更好地理解。 24 | 25 | ### 2.1 文档说明 26 | 27 | 为了观看体验和上传的方便,我将代码和文档分开了,文档在`./docs`文件夹下,代码在`./src`文件夹下。并且为了观看格式的统一,我将文档转为了PDF格式。 28 | 29 | ### 2.2 代码说明 30 | 31 | 由于文档中对模糊控制规则进行了对照试验,分为[25规则](./src/main.m)与[5规则](./src/test.m),所以代码也分为了两个版本。 32 | 33 | 另一方面,笔者在使用使用的matlab的时候,会有警告说相关的api即将被弃用(但是偷懒所以笔者没改),所以如果来者在跑代码的时候发现跑不通,可以提交[issue](https://github.com/SAKURA-CAT/water-tank/issues),我看到会尽快修复。 34 | 35 | > 或者提交[PR](https://github.com/SAKURA-CAT/water-tank/pulls)也行~ 36 | 37 | ## 3. 代码运行 38 | 39 | 导入matlab后直接运行即可。两份代码实际上只有在模糊规则定义的部分会有不同,但是为了单个文件的可执行性,会有一些重复的部分。 40 | 41 | ## 4. 其他 42 | 43 | 也没啥了,如果来者能够采纳我们小组的代码——或者我们的工作对你有所帮助,将是我们的荣幸。 44 | -------------------------------------------------------------------------------- /src/main.m: -------------------------------------------------------------------------------- 1 | % 水箱的数学模型函数: 2 | function y=func( h,u ) 3 | ki = 0.306; 4 | ko = 0.212; 5 | y = (-ko*sqrt(h)+ki*u)/(3.1415926*(1+2*sqrt(3)*h/3+(h^2)/3)); 6 | end 7 | % 主程序: 8 | %定义模糊控制器 9 | a=newfis('Water Tank'); 10 | %定义高度误差e的隶属度函数 11 | a=addvar(a,'input','e',[-1 1]); 12 | a=addmf(a,'input',1,'N','trapmf',[-1,-1,-0.8,0]); 13 | a=addmf(a,'input',1,'ZR','trimf' ,[-0.8,0,0.8]); 14 | a=addmf(a,'input',1,'P','trapmf',[0,0.8,1,1]); 15 | %定义高度误差变化率de的隶属度函数 16 | a=addvar(a,'input','de',[-1 1]); 17 | a=addmf(a,'input',2,'N','trapmf' ,[-1,-1,-0.8,0]); 18 | a=addmf(a,'input',2,'ZR','trimf' ,[-0.8,0,0.8]); 19 | a=addmf(a,'input',2,'B','trapmf' ,[0,0.8,1,1]); 20 | %定义输出变量(入水阀门开关度)u的隶属度函数 21 | a=addvar(a,'output','u',[-5 5]); 22 | a=addmf(a,'output',1,'NB','trapmf',[-5,-5,-4,-2]); 23 | a=addmf(a,'output',1,'NS','trimf',[-4,-2,0]); 24 | a=addmf(a,'output',1,'ZR','trimf',[-2,0,2]); 25 | a=addmf(a,'output',1,'PS','trimf',[0,2,4]); 26 | a=addmf(a,'output',1,'PB','trapmf',[2,4,5,5]); 27 | 28 | % 绘制定义的隶属度函数 29 | figure(1); 30 | 31 | % 绘制水位差e的隶属度函数 32 | subplot(2,1,1); 33 | plotmf(wt, 'input', 1); % 绘制水位差e的隶属度函数 34 | 35 | % 设置图标题和坐标轴标签 36 | title('水位差e的隶属度函数'); 37 | xlabel('水位差e'); 38 | ylabel('隶属度'); 39 | 40 | % 绘制水位变化率de的隶属度函数 41 | subplot(2,1,2); 42 | plotmf(wt, 'input', 2); % 绘制水位变化率de的隶属度函数 43 | 44 | % 设置图标题和坐标轴标签 45 | title('水位变化率de的隶属度函数'); 46 | xlabel('水位变化率de'); 47 | ylabel('隶属度'); 48 | 49 | 50 | %定义模糊规则 51 | rulelist = [1 0 5 1 2;2 1 4 1 1;2 2 3 1 1;2 3 2 1 1;3 0 1 1 2]; 52 | a=addrule(a,rulelist); 53 | 54 | %定义采样时间间隔 55 | T=1; 56 | %定义总采样点数 57 | N=2500; 58 | 59 | % 初始高度 60 | h = 10; 61 | %预想达到的液面高度 62 | hd1 = 5; 63 | 64 | e = h - hd1; %计算初始时刻的液面误差 65 | de = 0; %设定初始时刻液面误差变化率为0 66 | %误差变化率的系数,以求得模糊推理中论域内的误差变化率 67 | %针对de,其余两个参数设置为1 68 | kd = 5.9; 69 | %定义水箱进水口阀门的绝对开关量 70 | u1 = 0; 71 | 72 | % 保存采样集合 73 | hd = zeros(1, N); % 理想页面高度 74 | yy = zeros(1, N); % 实际高度 75 | ed = zeros(1, N); % 高度差e 76 | dd = zeros(1, N); % 高度差变化率de 77 | uu = zeros(1, N); % 阀门开启度 78 | 79 | 80 | % 开始采样 81 | for k = 1:N 82 | hd(1,k) = hd1; 83 | 84 | %求得论域内的误差变化率 85 | de1 = kd*de; 86 | if e>=1 87 | e=1; 88 | elseif e<=-1 89 | e=-1; 90 | end 91 | if de1>=1 92 | de1=1; 93 | end 94 | %输入模糊控制器的参数 95 | in = [e de1]; 96 | ed(1, k) = e; 97 | dd(1, k) = de1; 98 | 99 | %得出模糊控制器的输出结果(进水阀门开启或关闭的变化量 100 | u = evalfis(in,a); 101 | u1 = u1+u; %得到阀门此时的绝对开启量 102 | %判断此时阀门绝对开启量与最大开启量的关系 103 | if u1>=5 104 | u1=5; 105 | elseif u1<=0 106 | u1=0; 107 | end 108 | 109 | uu(1,k)=u1; %将每一采样点时刻的绝对开启量存入一数组uu 110 | %阀门绝对开启度作用于控制对象 111 | k1 = func(h,u1); 112 | k2 = func(h+T*k1/2,u1); 113 | k3 = func(h+T*k2/2,u1); 114 | k4 = func(h+T*k3,u1); 115 | h = h+(k1+2*k2+2*k3+k4)*T/6; %用龙格库塔法求出每一采样时刻的液面高度 116 | yy(1,k)=h; %将每一采样时刻液面高度存入数组yy 117 | e1 = e; %将误差赋给新变量e1 118 | e = h-hd(1,k); %求得新的误差 119 | de = (e-e1)/T; %得出新的误差变化率 120 | end 121 | 122 | % 页面高度变化 123 | figure(2); 124 | plot(1:N,hd,'k',1:N, yy,'r'); 125 | grid on 126 | xlabel('时间(秒)'); 127 | ylabel('液面高度'); 128 | 129 | % 阀门开启量变化 130 | figure(3); 131 | plot(1:N,uu,'b'); 132 | grid on 133 | xlabel('时间(秒)'); 134 | ylabel('输入阀门开关度'); 135 | 136 | % 创建一个新的图形窗口,并设置两个子图的位置 137 | figure(4); 138 | 139 | % 绘制输入e的变化曲线 140 | subplot(2,1,1); 141 | plot(1:N, ed, 'b'); 142 | xlabel('时间(秒)'); 143 | ylabel('e输入变化曲线'); 144 | 145 | % 绘制输入de的变化曲线 146 | subplot(2,1,2); 147 | plot(1:N, dd, 'b'); 148 | xlabel('时间(秒)'); 149 | ylabel('de输入变化曲线'); 150 | -------------------------------------------------------------------------------- /src/test.m: -------------------------------------------------------------------------------- 1 | function y = fu(h, u) 2 | ko = 0.5; 3 | ki = 0.067; 4 | y = (-ko*h + ki*u) / (3.1415926*(1 + 2*sqrt(3)*h/3 + (h^2)/3)); 5 | end 6 | 7 | 8 | %定义模糊控制器 9 | a = newfis('Water Tank'); 10 | %定义高度误差e的隶属度函数 11 | a=addvar(a,'input','e',[-2 2]); 12 | a = addmf(a, 'input', 1, 'N', 'trimf', [-3, -2, 0]); 13 | a = addmf(a, 'input', 1, 'ZO', 'trimf', [-1.5, 0, 1.5]); 14 | a = addmf(a, 'input', 1, 'P', 'trimf', [0, 2, 3]); 15 | %定义高度误差变化率de的隶属度函数 16 | a=addvar(a,'input','de',[-2 2]); 17 | a = addmf(a, 'input', 2, 'N', 'trimf', [-3, -2, 0]); 18 | a = addmf(a, 'input', 2, 'ZO', 'trimf', [-1.5, 0, 1.5]); 19 | a = addmf(a, 'input', 2, 'P', 'trimf', [0, 2, 3]); 20 | %定义输出变量(入水阀门开关度)u的隶属度函数 21 | a = addvar(a, 'output', 'u', [-2 2]); 22 | a = addmf(a, 'output', 1, 'NB', 'trimf', [-3, -2,-1]); 23 | a = addmf(a, 'output', 1, 'NS', 'trimf', [-2, -1, 0]); 24 | a = addmf(a, 'output', 1, 'ZO', 'trimf', [-1, 0, 1]); 25 | a = addmf(a, 'output', 1, 'PS', 'trimf', [0, 1, 2]); 26 | a = addmf(a, 'output', 1, 'PB', 'trimf', [1, 2, 3]); 27 | 28 | %定义模糊规则 29 | rulelist = [ 30 | 1 0 5 1 2; 31 | 2 1 4 1 1; 32 | 2 2 3 1 1; 33 | 2 3 2 1 1; 34 | 3 0 1 1 2 35 | ]; 36 | a=addrule(a,rulelist); 37 | showrule(a) 38 | 39 | 40 | % 绘制定义的隶属度函数 41 | figure(1); 42 | 43 | % 绘制水位差e的隶属度函数 44 | subplot(3, 1, 1); 45 | plotmf(a, 'input', 1); 46 | ylabel('隶属度函数'); 47 | xlabel('水位差e'); 48 | 49 | % 绘制水位变化率de的隶属度函数 50 | subplot(3, 1, 2); 51 | plotmf(a, 'input', 2); 52 | ylabel('隶属度函数'); 53 | xlabel('水位变化率de'); 54 | 55 | % 绘制阀门变量u的隶属度函数 56 | subplot(3, 1, 3); 57 | plotmf(a, 'output', 1); 58 | ylabel('隶属度函数'); 59 | xlabel('阀门开度u'); 60 | 61 | 62 | 63 | T = 1; %定义采样时间间隔 64 | N = 1000; %定义总采样点数 65 | h0 = 5; %预计达到的高度 66 | h = 10; %初始高度 67 | e = h - h0; %计算初始时刻的液面误差 68 | de = 0; %设定初始时刻液面误差变化率为0 69 | u1 = 0; %定义水箱进水口阀门的绝对开关量 70 | % 映射系数 71 | ke = 0.1; 72 | kd = 1.2; 73 | 74 | % 将u从论域中映射回真实角度 75 | ku = 45; 76 | 77 | % 保存采样集合 78 | h00 = zeros(1, N); %理想高度 79 | hh = zeros(1, N); %实际高度 80 | ee = zeros(1, N); %高度差e 81 | dee = zeros(1, N); %高度差变化率de 82 | uu = zeros(1, N); %阀门开启度变化率 83 | u11 = zeros(1, N); %阀门绝对开启度[0,90] 84 | 85 | %将模糊控制器作用于被控对象 86 | for k = 1:N 87 | %理想液面高度 88 | h00(1, k) = h0; 89 | 90 | e1 = ke*e; 91 | de1 = kd*de; 92 | if e1 >= 2 93 | e1 = 2; 94 | elseif e1 <=-2 95 | e1 = -2; 96 | end 97 | % 记录到集合 98 | ee(1, k) = e1; 99 | dee(1, k) = de1; 100 | 101 | in = [e1 de1]; 102 | u = evalfis(in, a); %得出模糊控制器的输出结果(进水阀门开启或关闭的变化量) 103 | if u >= 2 104 | u = 2; 105 | elseif u <= -2 106 | u = -2; 107 | end 108 | 109 | uu(1, k) = u; 110 | %阀门绝对开启量,题目限制为0到90度 111 | u1 = ku * u + u1; 112 | 113 | if u1 >=90 114 | u1=90; 115 | elseif u1<=0 116 | u1=0; 117 | end 118 | 119 | u11(1, k) = u1; 120 | 121 | %用龙格库塔法求出每一采样时刻的液面高度 122 | k1 = fu(h, u1); 123 | k2 = fu(h + T*k1/2, u1); 124 | k3 = fu(h + T*k2/2, u1); 125 | k4 = fu(h + T*k3, u1); 126 | h = h + (k1 + 2*k2 + 2*k3 + k4) * T/6; 127 | hh(1, k) = h; %将每一采样时刻液面高度存入数组hh 128 | 129 | e2 = e; %将误差赋给e2 130 | e = h - h0; %求得新的误差 131 | de = (e - e2) / T; %得出新的误差变化率 132 | end 133 | 134 | %将每一采样时刻构成的时间序列作为一时间轴 135 | kk = 1:N; 136 | 137 | %画出预想的液面高度,以及实际液面高度随时间的变化 138 | figure(2); 139 | plot(kk, hh, 'k', kk, h00, 'r'); 140 | grid on 141 | xlabel('时间(秒)'); 142 | ylabel('液面高度'); 143 | legend('实际高度', '预期高度') 144 | 145 | %画出进水阀门的绝对开启量随时间的变化 146 | figure(3); 147 | plot(kk, uu, 'b'); 148 | grid on 149 | xlabel('时间(秒)'); 150 | ylabel('模糊控制器输出曲线'); 151 | 152 | % 创建一个新的图形窗口,并设置两个子图的位置 153 | figure(4); 154 | % 绘制输入e的变化曲线 155 | subplot(2, 1, 1); 156 | plot(kk, ee, 'b'); 157 | xlabel('时间(秒)'); 158 | ylabel('e输入变化曲线'); 159 | 160 | % 绘制输入de的变化曲线 161 | subplot(2, 1, 2); 162 | plot(kk, dee, 'b'); 163 | xlabel('时间(秒)'); 164 | ylabel('de输入变化曲线'); 165 | 166 | %画出进水阀门的绝对开启量随时间的变化 167 | figure(5); 168 | plot(kk, u11, 'b'); 169 | grid on 170 | xlabel('时间(秒)'); 171 | ylabel('输入阀门绝对开关度'); 172 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [Cunyue] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------