function err=errcheck(str, flag)
global v lv rv vn_vars
err = 0;
check_obj = 1;
check_cons = 2;
check_bounds = 3;
if (isempty(str)) err = 1; return; end
tmpstr = str(find(str ~= ' ' & str ~= 0));
operator = find(tmpstr == '=' | tmpstr == '>' | tmpstr == '<' );
if (~isempty(operator))
if (operator(1) == 1 | operator(length(operator)) == length(tmpstr))
err = errmessage('Input incomplete'); return;
end
end
operator = find(tmpstr == '+' | tmpstr == '-' );
if (~isempty(operator))
if ( operator(length(operator)) == length(tmpstr))
err = errmessage('Input incomplete'); return;
end
end
% coefficient check ......
lbrace = find(str == '{');
rbrace = find(str == '}');
len = length(lbrace);
if ( len ~= length(rbrace) )
errmessage('Braces unmatched'); return;
end
if (len ~= 0)
tmpstr =['+' tmpstr 'z'];
tmplbrace = find(tmpstr == '{');
tmprbrace = find(tmpstr == '}') ;
patt = [];
for i = 1:len
if (~isletter(tmpstr(tmprbrace(i)+1)) &...
isempty(findstr(tmpstr(tmprbrace(i)+1),'+-<>='))) |...
isempty(findstr(tmpstr(tmplbrace(i)-1),'+-<>='))
errstr = 'A coefficient must be a number or an expression in "{}"';
err = errmessage(errstr);
return;
end
if (rbrace(i)-lbrace(i) <2)
errmessage('Empty {}'); return;
end
inner = lbrace(i):rbrace(i);
patt = [patt inner];
lbracket = find(str(inner) == '(');
rbracket = find(str(inner) == ')');
if (length(lbracket) ~= length(rbracket))
err = errmessage(' "(" dose not match ")" '); return;
end
end
str(patt) = [];
end
% general checking ......
error = ~( ...
str == '+' | str == '-' | str == '.' | str == ' ' ...
| str == 0 | str == '=' | str == '<' | str == '>' ...
| (str >= '0' & str <= '9') | isletter(str));
if any(error)
errstr = str(find(error));
err = errmessage(['Illegal charactor(s): ' errstr]); return; end
operator = (find(str == '+' | str == '-' ));
len = length(operator);
if (len > 1)
error = any(operator(2:len) - operator(1:len-1) == 1);
if any(error)
err = errmessage('Successive operators not allowed'); return;
end
end
% objective check ......
if (flag == check_obj)
error = (str == '=' | str == '>' | str == '<');
if any(error)
err = errmessage('"=", "<" or ">" not allowed in objective');
return;
end
nonblank = find(str ~= ' ');
s3 = lower(str(nonblank(1):nonblank(1)+2));
if any(s3 ~= 'max') & any(s3 ~= 'min')
err = errmessage('Max or min must appear first in objective');
return;
else
str=str(nonblank(1)+3:length(str));
end
end
% constraints checking ......
if (flag == check_cons)
operator = find(str == '=' | str == '>' | str == '<');
if (length(operator) ~= 1)
err = errmessage('Use one and only one of "=", "<" or ">"');
return;
end
end
% bounds checking ......
if (flag == check_bounds)
if (~isempty(find(str == '=')))
err = errmessage('NO "=" allowed in bounds'); return;
end
operator = find(str == '>' | str == '<' );
len_op = length(find(str == '>' | str == '<' ));
if (len_op < 1 | len_op > 2)
err = errmessage('There must be 1 or 2 inequalities in a bound');
return;
elseif (len_op == 2)
gt = length(find(str == '>'));
lt = length(find(str == '<'));
if (~(gt == 2 | lt == 2))
err = errmessage('Misused ">" or "<"');
return;
end
end
interval = [0 operator length(str)+1];
for i = 1:length(interval)-1
substr = str(interval(i)+1:interval(i+1)-1);
if (isempty(substr)) substr = '9'; end
substr = substr(find(substr ~= ' '));
subletter = find((substr >= 'A' & substr <= 'Z') | ...
(substr >= 'a' & substr <= 'z') );
if(~isempty(substr))
subop = find(substr =='+' | substr =='-' | substr =='*');
else
subop = [];
end
if (~isempty(subletter))
if (subletter(1) ~= 1)
err = errmessage('Coefficients on variables not allowed');
return;
end
if (~isempty(subop))
err = errmessage('Arithmatic operators on variables not allowed');
return;
end
end
end
letter = find((str >= 'A' & str <= 'Z') | (str >= 'a' & str <= 'z'));
len_letter = length(letter);
if (len_letter == 0) err = errmessage('No variable'); return; end
error = (letter(1) < operator(1) & letter(len_letter) > operator(1)) ...
| (letter(1) < operator(len_op) & ...
letter(len_letter) > operator(len_op)) ...
| (len_op == 2 & letter(1) < operator(1)) ...
| (len_op == 2 & letter(len_letter) > operator(len_op));
if any(error)
err = errmessage('Illegal expression in bounds');
return;
end
end
% blank space check ......
nonblank = str ~= ' ';
slen = length(nonblank);
nonblank = [nonblank 1];
for i = 1:slen
if (nonblank(i) == 0 & nonblank(i+1) == 1) nonblank(i) = 1 ; end
end
nonblank = nonblank(1:slen);
str = str(find(nonblank == 1));
str = ['@' str '@'];
blank = find(str == ' ');
if (~isempty(blank))
b_blank = str(blank -1);
a_blank = str(blank +1);
error = ( (b_blank >= '0' & b_blank <= '9') & ...
(a_blank >= '0' & a_blank <= '9') ) ...
| ( isletter(b_blank) & isletter(a_blank) ) ...
| ( isletter(b_blank) & (a_blank >= '0' & a_blank <= '9') );
if any(error) err = errmessage('Space in wrong place'); return; end
end
没有合适的资源?快使用搜索试试~ 我知道了~
lipsolWIN32.zip_Linear programming
共96个文件
m:55个
f:12个
dll:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 73 浏览量
2022-07-14
13:33:16
上传
评论
收藏 235KB ZIP 举报
温馨提示
linear and nonlinear programming solver
资源推荐
资源详情
资源评论
收起资源包目录
lipsolWIN32.zip (96个子文件)
lipsol
matdir
afiro.mat 5KB
recipe.mat 22KB
mexdir
UserGuide_ps.ps 42KB
mpsdir
kb2.mps 10KB
pilot4.mps 179KB
readmeWIN32 843B
src
ordmmd.f 36KB
blkfct.f 73KB
mps2mat.f 17KB
blkslv.f 4KB
mps2matg.f 3KB
inpnvg.f 5KB
mexopts.sh 7KB
symfct.f 77KB
blkslvg.f 4KB
blkfctg.f 5KB
symfctg.f 8KB
ordmmdg.f 4KB
readme 766B
.mexrc.sh 9KB
inpnv.f 3KB
COPYRIGHT 798B
lppdir
test2.lpp 214B
test1.lpp 178B
example.lpp 249B
batch
lipsbg.m 2KB
output
config.rc 7B
prob.rc 7B
probs
prob.netlib 667B
prob.sample 23B
runbg 624B
readme 403B
startup.m 2KB
readmeUNIX 1KB
solvers
miip
feasibility.m 587B
pcg.m 997B
centering.m 715B
errornobj.m 629B
complementy.m 381B
sherman.m 548B
direction.m 894B
stopping.m 1KB
densol.m 811B
clearglobal.m 668B
update.m 1KB
ratiotest.m 518B
detectinf.m 868B
spsol.m 275B
miip.m 2KB
initpoint.m 974B
getpu.m 575B
parameters.m 261B
getmisc.m 464B
printout.m 2KB
lpmex
ordmmd.dll 44KB
symfct.dll 60KB
inpnv.dll 36KB
blkslv.dll 36KB
mps2mat.dll 68KB
blkfct.dll 72KB
lipcomm
readlpp.m 4KB
listmat.m 228B
runlipsol.m 1KB
listall.m 489B
sol2lpp.m 765B
recipe.mat 22KB
.lppfun
errcheck.m 5KB
errmessage.m 92B
transbnd.m 3KB
vsearch.m 188B
checkbnds.m 651B
transobj.m 2KB
transcon.m 3KB
parsebnds.m 642B
Authors 92B
lpformats.m 3KB
savelpp.m 1KB
Contents.m 758B
lipconfig.m 2KB
viewlpp.m 224B
listlpp.m 226B
listmps.m 227B
lib
project.m 494B
monitor.m 1KB
loadata.m 1KB
checkdense.m 776B
symbfct.m 1KB
preprocess.m 5KB
linsys.m 2KB
findprob.m 2KB
postprocess.m 869B
reciprocal.m 467B
scaling.m 1KB
solaat.m 493B
startup.m 2KB
www.pudn.com.txt 218B
共 96 条
- 1
资源评论
APei
- 粉丝: 64
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功