Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark mode
Gurobi Example Tour
Light LogoDark Logo
Gurobi
Back to top

params.m#

functionparams(filename)% Copyright 2025, Gurobi Optimization, LLC%% Use parameters that are associated with a model.%% A MIP is solved for a few seconds with different sets of parameters.% The one with the smallest MIP gap is selected, and the optimization% is resumed until the optimal solution is found.% Read modelfprintf('Reading model %s\n',filename);model=gurobi_read(filename);ivars=find(model.vtype~='C');iflength(ivars)<=0fprintf('All variables of the model are continuous, nothing to do\n');return;end% Set a 2 second time limitparams.TimeLimit=2;% Now solve the model with different values of MIPFocusparams.MIPFocus=0;result=gurobi(model,params);bestgap=result.mipgap;bestparams=params;fori=1:3params.MIPFocus=i;result=gurobi(model,params);ifresult.mipgap<bestgapbestparams=params;bestgap=result.mipgap;endend% Finally, reset the time limit and Re-solve model to optimalitybestparams.TimeLimit=Inf;result=gurobi(model,bestparams);fprintf('Solution status: %s, objective value %g\n',...result.status,result.objval);end

Help and Feedback


[8]
ページ先頭

©2009-2025 Movatter.jp