Movatterモバイル変換


[0]ホーム

URL:


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

sos.m#

functionsos()% Copyright 2025, Gurobi Optimization, LLC%% This example creates a very simple Special Ordered Set (SOS)% model. The model consists of 3 continuous variables, no linear% constraints, and a pair of SOS constraints of type 1.model.ub=[112];model.obj=[211];model.modelsense='Max';model.A=sparse(1,3);model.rhs=0;model.sense='=';% Add first SOS: x1 = 0 or x2 = 0model.sos(1).type=1;model.sos(1).index=[12];model.sos(1).weight=[12];% Add second SOS: x1 = 0 or x3 = 0model.sos(2).type=1;model.sos(2).index=[13];model.sos(2).weight=[12];% Write model to filegurobi_write(model,'sos.lp');result=gurobi(model);fori=1:3fprintf('x%d %e\n',i,result.x(i))endfprintf('Obj: %e\n',result.objval);end

Help and Feedback


[8]
ページ先頭

©2009-2025 Movatter.jp