資源簡介
混合整數非線性規劃matlab代碼,需要者請下吧~

代碼片段和文件信息
%?NONLINEAR?MIXED?INTEGER?PROGRAM?SOLVER
%???This?program?solves?mixed?integer?problems?with?a?branch?and?bound
%???method.
%
%???Further?work:
%???Add?heuristics?to?create?a?good?initial?integer?solution
%???Add?cuts?to?the?problem?(branch?and?cut?method)
%
%???Some?testing?with?the?problem?shows?that?it?works?well?with?up?to?
%???around?30?integer?variables?and?10000?nlp?variables.
%
%?Version?1?-?MILP?by?Thomas?Tr鰐scher?2009
%?Version?2?-?MINLP?by?John?Hedengren?2012
%?Results:
%?x_best?-?best?integer?solution?found
%?f_best?-?best?objective?found
clear?all
close?all
tic;
addpath(‘apm‘)
%?select?server
%server?=?‘http://apmonitor.com‘;
%server?=?‘http://byu.apmonitor.com‘;
server?=?‘http://xps.apmonitor.com‘;
%?application?name
app?=?‘minlp‘;
%?clear?previous?application
apm(serverapp‘clear?all‘);
%?load?model?(can?edit?with?text?editor)
edit?minlp.apm
apm_load(serverapp‘minlp.apm‘);
%
%?Local?Options
%
o.display?=?‘iter‘;
%?Algorithm?display?[iterimprovefinaloff]
%
o.iterplot?=?true;
%?Plot?upper?and?lower?bounds?on?objective?function?value?while?iterating
%?[truefalse]
%
o.solver?=?1;
%?NLP?solver?(1=apopt2=bpopt3=ipoptetc)
%
o.Delta?=?1e-8;
%?Stopping?tolerance?of?the?gap?(f_integer-f_lp)/(f_integer+f_lp)
%
o.maxNodes?=?1e5;
%?Maximum?number?of?nodes?in?the?branch?and?bound?tree?to?visit
%
o.branchMethod?=?3;
%?1?-?depth?first?2?-?breadth?first?3?-?lowest?cost?4?-?highest?cost
%
o.branchCriteria?=?1;?
%?1?-?most?fractional?2?-?least?fractional?3?-?highest?cost?4?-?lowest?cost
%
o.intTol?=?1e-6;
%?Integer?tolerance
apm_option(serverapp‘nlc.solver‘o.solver);
apm_option(serverapp‘nlc.imode‘3);
%Small?test?problem?optimal?solution?should?be?-21
lb?=?[0?0?0?0]‘;
ub?=?[1?1?1?1]‘;
yidx?=?true(41);
nx?=?size(lb1);
for?j?=?1:nx
????xi?=?[‘x[‘?int2str(j)?‘]‘];
????apm_info(serverapp‘SV‘xi);
end
%Assume?no?initial?best?integer?solution
%Add?your?own?heuristic?here?to?find?a?good?incumbent?solution?store?it?in
%f_besty_bestx_best
f_best?=?inf;
y_best?=?[];
x_best?=?[];
%Variable?for?holding?the?objective?function?variables?of?the?lp-relaxation
%problems
f?=?inf(o.maxNodes1);
f(1)?=?0;
fs?=?inf;
numIntSol?=?double(~isempty(y_best));
%Set?of?problems
S?=?nan(sum(yidx)1);
D?=?zeros(sum(yidx)1);
%The?priority?in?which?the?problems?shall?be?solved
priority?=?[1];
%The?indices?of?the?problems?that?have?been?visited
visited?=?nan(o.maxNodes1);
%Plot?each?iteration?
i=0;
if?o.iterplot
????figure;
????hold?on;
????title(‘Bounds‘)
????xlabel(‘Iteration‘)
????ylabel(‘Obj.?fun.?val‘)
end
%%?Branch?and?bound?loop
while?i==0?||?isinf(f_best)?||?(~isempty(priority)?&&??((f_best-min(fs(priority)))/abs(f_best+min(fs(priority)))?>?o.Delta)?&&??i ????%Is?the?parent?node?less?expensive?than?the?current?best
????if?i==0?||?fs(priority(1)) ????????%Solve?the?LP-relaxation?problem
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????408??2012-03-17?03:42??apm\apm.m
?????文件?????????494??2012-03-17?03:42??apm\apm_info.m
?????文件?????????760??2012-03-17?03:42??apm\apm_load.m
?????文件?????????336??2012-03-17?03:42??apm\apm_meas.m
?????文件?????????176??2012-03-17?03:42??apm\apm_option.m
?????文件?????????923??2012-03-17?03:42??apm\apm_sol.m
?????文件?????????391??2012-03-17?03:42??apm\apm_t0.m
?????文件?????????294??2012-03-17?03:42??apm\apm_tag.m
?????文件?????????544??2012-03-17?03:42??apm\apm_var.m
?????文件?????????545??2012-03-17?03:42??apm\apm_web.m
?????文件?????????477??2012-03-17?03:42??apm\csv_data.m
?????文件?????????357??2012-03-17?03:42??apm\csv_element.m
?????文件?????????766??2012-03-17?03:42??apm\csv_load.m
?????文件?????????352??2012-03-17?03:42??apm\csv_lookup.m
?????文件?????????287??2012-03-17?03:42??apm\parse.m
?????文件????????1036??2012-03-19?12:55??minlp.apm
?????文件???????10028??2012-03-19?14:16??minlp.m
?????文件????????1542??2014-02-12?13:54??license.txt
- 上一篇:基于VHDL語言的在FPGA上產生單相SPWM波形
- 下一篇:JPEG圖像壓縮編碼
評論
共有 條評論