Skip to content

Instantly share code, notes, and snippets.

@mosekadmin
Created March 3, 2016 13:59
def oven2(N, M, A, T):
AS = [ 1./math.sqrt(a) for a in A ]
with Model() as m:
x = m.variable('x', N, Domain.greaterThan(0.) )
y = m.variable('y', N, Domain.inRange(0.,1.0), Domain.isInteger() )
t = m.variable('t', 1, Domain.unbounded() )
m.constraint( Expr.sum(x) , Domain.equalsTo(T) )
m.constraint( Expr.sub( x, Expr.mulElm( M, y) ), Domain.lessThan(0.) )
m.constraint( Expr.vstack( 0.5, t, Expr.mulElm(AS, Expr.sub(A,x)) ), Domain.inRotatedQCone() )
m.objective( ObjectiveSense.Minimize, Expr.sub( t, Expr.dot( A, Expr.sub(1., y ) ) ) )
m.setLogHandler(sys.stdout)
m.solve()
return x.level(), y.level()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment