random.m
来自「线性规划 包括单纯形法」· M 代码 · 共 32 行
M
32 行
%--------------随机法------------%
function y = random(x,N)
la = 1;
eps = 1/10^12;
x = x';
temp = x;
i = 1;
while la >= eps
while i <= N
u = rand(2,1);
new = x + la.* u;
fun_pre = fun(x);
fun_new = fun(new);
if fun_new < fun_pre
while fun_new < fun_pre
x = new;
new = x + la.*u;
fun_pre = fun(x);
fun_new = fun(new);
i = 1;
end
else
i = i + 1;
end
end
la = la/N;
i = 1;
end
x
fmin = fun(x)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?