Problem_Set_6sol
- 格式:pdf
- 大小:127.68 KB
- 文档页数:5
Lpsolve常见问题集译者:李松Email:lisong20020715@目录1.前言 (2)2.在哪里能找到lp-solve最新的源码? (2)3.我可以在商业用途的代码中使用lp-solve吗? (2)4.能否解释一下GNU 较宽松公共许可证(LGPL)的确切含义?我看不明白。
(2)5.我需要花多少钱才能使用lp-solve? (3)6.我在使用lp-solve的时候,如何声明其版权信息? (3)7.对于变量,其缺省(默认)的上下限是多少? (3)8.变量的下限能否是负数? (3)9.能否将变量的下限设为负无穷大? (3)10.我在调用API函数solve()的时候,在屏幕上会打印出很多信息。
我能否屏蔽掉这些信息? (4)11.Lp-solve不能求解我的模型或求解时间过长。
怎么办? (4)12.Lp-solve能求解非线性公式吗? (4)13.Lp-solve将输出信息打印在屏幕上。
能不能也存到文件中? (4)14.我有一个限制是x < 2,但Lp-solve得到的解中有 x = 2,这是怎么回事? (4)15.在求解我的模型时,Lp-solve出现了堆栈溢出/core dump/保护错误。
请问怎么回事? (4)16.在求解我的模型时,版本4比版本3还要慢。
我该怎么办? (5)17.在使用API接口创建模型时,花费了很长时间。
尤其是add_constraint,add_constraintex,str_add_constraint这几个函数似乎很慢。
怎么才能使它快一点? (5)18.Lp-solve能不能输出“单纯形表格”? (5)19.Lp-solve能处理的行/列的最大数目是多少? (5)20.我所使用的编程语言不在Lp-solve的支持列表之内,或者没有相应的例子。
那么我能在里面调用lp-solve吗? (5)21.那个Windows例子不能用。
在运行时会报错。
有些动态库找不到。
[警告错误信息]【错误和警告信息汇总】(此贴为复件,请勿回复)[复制链接]zsq-w管理员CIO仿真币33975阅读权限255 电梯直达1#发表于 2009-5-7 17:08:16 |只看该作者|倒序浏览本帖最后由 zsq-w 于 2009-6-2 17:11 编辑*************************错误与警告信息汇总*************************--------------简称《错误汇总》***ERROR***WARNING***二次开发%%%%%%%%%%%%%%% @@@ 布局@@@ &&&&&&&&&&&&&&&&&&&&&&常见错误信息常见警告信息网格扭曲cdst udio斑竹总结的fortran二次开发的错误表%%%%%%%%%%%%%%%%% @@@@@@ &&&&&&&&&&&&&&&&&&&&&&&&&模型不能算或不收敛,都需要去monitor,msg文件查看原因,如何分析这些信息呢?这个需要具体问题具体分析,但是也存在一些共性。
这里只是尝试做一个一般性的大概的总结。
如果你看见此贴就认为你的warning以为迎刃而解了,那恐怕令你失望了。
不收敛的问题千奇万状,往往需要头疼医脚。
接触、单元类型、边界条件、网格质量以及它们的组合能产生许多千奇百怪的警告信息。
企图凭一个警告信息就知道问题所在,那就只有神仙有这个本事了。
一个warning出现十次能有一回参考这个汇总而得到解决了,我们就颇为欣慰了。
报错Error EDDDAV: Call to ZHEGV failed. Returncode = 7 1 8Serial version problems:Problem 1 : Error EDDDAV: Call to ZHEGV failed.Problem 2 : lib-4201 : UNRECOVERABLE library errorProblem 3 : WARNING in EDDRMM: call to ZHEGV failed, returncode = 6 3 9Parallel version problems:Will be added at some later dateProblem 1)The test calculation for copper system (benchmark.tar.gz, download from the VASP ftp-server) stops with an error message:"Error EDDDAV: Call to ZHEGV failed. Returncode = 9 1 8".The actual numbers change at the end of the error, but the message means that a LAPACK library call failed.Solution:The subroutine davidson.F must be handled with lower optimization settingAdd the following lines to the end of the VASP Makefile:davidson.o : davidson.F$(CPP)$(FC) $(FFLAGS) -O1 -c $*$(SUFFIX)(You remembered to use the TAB key instead of spaces with the second and the third line, right?)Problem 2)After lowering the davidson subroutine optimization level the calculation ends with another error:"lib-4201 : UNRECOVERABLE library error: Unable to find error message (check NLSPATH, file lib.cat)Encountered during a direct access unformatted READ from unit 21. Fortran unit 21 is connected to a direct unformatted unblocked file: "TMPCAR"/opt/gridengine/default/spool//compute-0-4/job_scripts/10170: line 31: 16997 Aborted (core dumped) ./vasp_path_serial >vasp_path_serial.out" Solution:Change/add the IWAVPR=10 line to your INCAR file. This is from the VASP manual, FAQ section, page 149"Question: I am running VASP on a SGI Origin, and the simple benchmark (benchmark.tar.gz) fails with lib-4201 : UNRECOVERABLE library error READ operation tried to read past theend-of-record.Encountered during a direct access unformatted READ from unit 21 Fortran unit 21 is connected to a direct unformatted unblocked file: "TMPCAR" IOT TrapAbort (core dumped)Answer: VASP extrapolates the wave functions between molecular dynamics time steps. To store the wave functions of the previous time steps either a temporary scratch file (TMPCAR) is used (IWAVPR=1-9) or large work arrays are allocated (IWAVPR=11-19).On the SGI, the version that uses a temporary scratch file does not compile correctly, and hence the user has to set IWAVPR to 10."Problem 3)When running the Hg benchmark (bench.Hg.tar.gz), the OUTCAR file has numerous lines saying:"WARNING in EDDRMM: call to ZHEGV failed, returncode = 6 3 9" Solution:This issue is addressed in the VASP support forum(http://cms.mpi.univie.ac.at/vasp-forum/forum_viewtopic.php?3.214) Short summary is given here. Possible reasons (this may, once again, be connected to failures calling LAPACK routines):1) The diagonalization algorithm is not stable for your system-> Change ALGO = Normal or ALGO = Fast in your INCAR file2) Your geometry is not reasonable. Maybe your initial structure or the algorithm handling ion relaxation is giving a bad structure-> Switch to a different ion relaxation scheme (IBRION line in your INCAR)-> Reduce the step size of the first step by reducing the POTIM value in your INCAR你的几何学不合理。
1. CPLEX的获取1)公司花钱2)申请IBM学术版2. CPLEX的使用方式1) OPL IDE,对应的命令为oplide。
优点:基于Eclipse的IDE,功能丰富。
缺点:内存消耗大,不能支持打印中间可行解。
2) 命令行方式,对应的命令为oplrun优点:内存消耗较小缺点:不能支持打印中间可行解3) 对应的交互方式,对应的命令为cplex优点:内存消耗小,可以通过中断-恢复计算的方式,查看中间解;也可以通过设置参数set output intsolfileprefix...存储每个可行解缺点:命令行4. 建议修改的非默认选项,用于改善速度或内存开销(整数规划MIP)1)set output intsolfileprefix设置存储每个可行解的文件2)set output writelevel 4设置存储可行解的详细程度3)set mip interval 100设置log的间隔时间4) set workmem 256设置工作内存空间大小,默认128M5)set mip strategy file 3默认情况下,搜索节点的大小超过工作空间大小,就会被转换成节点文件——压缩存储在内存中可以设置成将节点文件存储在磁盘中,从而节省内存开销——会带来额外的计算开销常见问题1 从opl模型文件导出lp、mps等规划问题的标准格式?利用opl ide中的导出功能:在设置文件中勾选,然后运行该配置知道预处理完成就可以在工作目录下看到对应的导出文件2 得到第一个可行解后就停止求解?/support/docview.wss?uid=swg214000893 如何重用cplex参数1) 从当前环境导出参数(默认文件cplex.par)cplex>display settings changed (该命令会在控制台打印所有参数及参数值,同时将这些信息存储到log文件中)从log文件中复制这些信息,并保存到cplex执行目录下的cplex.par文件中(如果使用别的文件名,需要修改环境变量CPLEXPARFILE)2)使用cplex.par文件将cplex.par文件放在cplex执行目录就行了参考:4. 如何从某个可行解开始求解MIP?1) 得到可行解可以用启发式方法得到,但是需要保存成MST或者sol文件格式(参考cplex文档)也可以利用上次运行得到的可行解,即cplex>write start.sol m8(其中m8是cplex已经算出来的可行解的名字,可以用display命令进行查看)参考:/infocenter/cosinfoc/v12r2/index.jsp?topic=%2Filog.odms.cplex.hel p%2FContent%2FOptimization%2FDocumentation%2FCPLEX%2F_pubskel%2FCPLEX 570.html2) 利用可行解作为初始解cplex>read problem.lpcplex>read start.solcplex>optimize5. 如果cplex求解长时间得不到更好的可行解,怎么办?1)修改emphasis mip参数为1,使得求解可行解优先而非最优性优先2)修改mip strategy heuristicfreq,提高应用node启发式的频率3)修改mip strategy nodeselect为best-estimate策略来搜索下一个节点,有时更容易找到可行解4)利用Solution polishing,基于当前可行解来改进5)修改mip strategy variableselect为3,启用strong branching参考:/support/docview.wss?uid=swg21399949file:///C:/Program%20Files/IBM/ILOG/CPLEX_Studio125/doc/html/en-US/CPLEX/UsrMan /topics/discr_optim/mip/troubleshoot/56_find_more_feas.htmlfile:///C:/Program%20Files/IBM/ILOG/CPLEX_Studio125/doc/html/en-US/CPLEX/UsrMan /topics/discr_optim/mip/troubleshoot/58_best_node_stuck.html6. 如何得到中间可行解的方案?1)利用cplex的display命令和log文件2)设置cplex中的output intsolfileprefix参数,自动保存每个中间可行解7. “out of memory”问题分析参考:/support/docview.wss?uid=swg214000518. 评估MIP模型的难度及可能存在的问题参考:MIP kappa: detecting and coping with ill-conditioned MIP models。
Harvard University Economics1123Department of Economics Spring2006Problem Set6–Suggested AnswersThank you for smokingDue:Thursday6April.Question1.(a)Estimate the probability of smoking for(i)all workers in the sample(ii)workers affected by smoking bans(iii)workers not affected by smoking bansUsing the summarize command wefind that24.2%of the sample are smokers.From the linear probability model estimates(next question)I have that29.0%of those without a smoking ban are smokers and29.0-7.8=21.2%are smokers in places where there are bans.(b)What is the difference in the probability of smoking between workers affected by a workplace smoking ban and workers not affected by a workplace smoking ban?Use a linear probability model to test whether or not this difference is statistically significant.The results of the linear probability model are\smo ker=0.290−0.078∗smkban(0.007)(0.009)The hypothesis we want to test is H0:β1=0versus H a:β1=0.The t statistic is-0.078/0.009=-8.66.This is far outside the acceptance region of being within±1.96and so we reject the hypothesis that banning smoking in the workplace has no effect on whether or not the person is a smoker.(c)Estimate a linear probability model with smoker as the dependent variable and the following regressors:smkban,female,age,age2,hsdrop,colsome,colgrad,black and e the robuster-rors pare the estimated effect on smoking of the ban in this regression to that of1(b). What is the change in the effect,and suggest a reason for the difference.The Stata output for this regression is(d)In the regression in1(c),test(at the5%level)that smkban has no effect on smoking. The hypothesis we want to test is still H0:β1=0versus H a:β1=0.The t statistic is -0.047/0.009=-5.27.This is still statistically significantly different from zero.Hence we still reject, after controlling for other variations in the propensity for people to smoke,that banning smoking has no effect on the probability that a person smokes.(e)Test the hypothesis that the level of education has no effect on smoking in the regression in 1(c).Use a test with size5%.There are four education variables,we can use an F test to test the coefficients for zero.The null hypothesis is that the coefficients on hsdrop,hsgrad,colsome,colgrad are all jointly zero against the alternative that one or more is non zero.The reason is that if any are nonzero then education has an effect on the probability that a person smokes.The value for the F statistic is140.09,which is easily larger than the critical value of2.37and hence we cation does have an effect on the probability that a person smokes.The Stata output isQuestion2.Estimate a probit model using the same regressors as in1(c).Use the robust errors option.The Stata output is(a)Test the same hypothesis as in part1(d)but now for this probit regression.The hypothesis we want to test is still H0:β1=0versus H a:β1=0.The t statistic is 0.-0.159/0.029=-5.45.Hence we still reject in the probit regression that the ban has no effect on the probability that a person smokes.(b)Consider a hypothetical individual,Mr A.,who is white,non-hispanic,30years old and a high school dropout.Suppose this person is subject to the wordplace smoking ban,and caclulate the predicted probability that this person pute the probability this person smokes if they are not subject to a work ban.(c)Consider another hypothetical individual,Ms B,who is the same demographically to Mr A except she completed high pute the probabilities that she smokes when there is a workplace ban and when there is no ban.For the answers in both(b)and(c),we can place them in a table.Note that I had Stata compute these,see the Statafile at the end of the problem set.Mr A Ms BBan0.4450.306No Ban0.5080.363Difference-0.063-0.057(d)Are the results on the effect of the ban the same for each of these hypothetical people?Why or why not?The results are basically the same.They need not have been,given that the estimated proba-bility depends on all of the factors.(e)Compare the results you obtain from2(b)and2(c)and compare them to the effect in the linear probability model in1(c).What is going on?The linear probability model gives an effect of a decrease of4.7%for all possible demographic groups.This is less a problem with the linear probability model than the fact that the specification of the LPM does not allow for demographic effects to impact the effect of the smoking ban.We could of course have interacted the smkban dummy variable with some of the demographic variables, and then we would have had differing effects just as the probit has differing effects.Of course,thereason we use a probit in thefirst place is that it is sensible to impose nonlinearities on the model to ensure that the predicted probabilities remain inside the bounds for all possible values for the covariate,which would be hard to do for the LPM.Stata dofile to compute the resultsclear#delimit;capture log close;/*Ps6—smoking example*/log using c:\1123\ps6_01.log,replace;use C:\1123\smoking.dta;desc;su;gen age2=age*age;summarize;regress smoker smkban,robust;regress smoker smkban female age age2hsdrop hsgrad colsome colgrad black hispanic,robust;test hsdrop hsgrad colsome colgrad;probit smoker smkban female age age2hsdrop hsgrad colsome colgrad black hispanic,robust;sca mra1=_b[_cons]+_b[smkban]*1+_b[female]*0+_b[age]*30+_b[age2]*900+_b[hsdrop]*1+_b[hsgrad]*0+_b[colsome]*0+_b[colgrad]*0+_b[black]*0+_b[hispanic]*0;dis"mr A,ban"mra1;gen pmra1=normprob(mra1);dis pmra1;sca mra0=_b[_cons]+_b[smkban]*0+_b[female]*0+_b[age]*30+_b[age2]*900+_b[hsdrop]*1+_b[hsgrad]*0+_b[colsome]*0+_b[colgrad]*0+_b[black]*0+_b[hispanic]*0;dis"mr A,no ban"mra0;gen pmra0=normprob(mra0);dis pmra0;sca msa1=_b[_cons]+_b[smkban]*1+_b[female]*1+_b[age]*30+_b[age2]*900+_b[hsdrop]*0+_b[hsgrad]*1+_b[colsome]*0+_b[colgrad]*0+_b[black]*0+_b[hispanic]*0;dis"ms A,ban"msa1;gen pmsa1=normprob(msa1);dis pmsa1;sca msa0=_b[_cons]+_b[smkban]*0+_b[female]*1+_b[age]*30+_b[age2]*900+_b[hsdrop]*0+_b[hsgrad]*1+_b[colsome]*0+_b[colgrad]*0+_b[black]*0+_b[hispanic]*0;dis"ms A,no ban"msa0;gen pmsa0=normprob(msa0);dis pmsa0;log close;clear; exit;。