Skip to content

Commit

Permalink
Merge pull request #101 from JuliaOpt/ml/objectivesense
Browse files Browse the repository at this point in the history
rename Sense attribute to ObjectiveSense
  • Loading branch information
mlubin committed Aug 2, 2017
2 parents 7f62532 + 608cf89 commit 7eadf4e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/src/apireference.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ List of solver instance attributes

```@docs
RawSolver
Sense
ObjectiveSense
NumberOfVariables
ListOfVariableReferences
ListOfConstraints
Expand Down
6 changes: 3 additions & 3 deletions src/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ The total elapsed solution time (in seconds) as reported by the solver.
struct SolveTime <: AbstractSolverInstanceAttribute end

"""
Sense()
ObjectiveSense()
The optimization sense of the solver instance, an `OptimizationSense` with value `MinSense`, `MaxSense`, or `FeasiblitySense`.
The sense of the objective function, an `OptimizationSense` with value `MinSense`, `MaxSense`, or `FeasiblitySense`.
"""
struct Sense <: AbstractSolverInstanceAttribute end
struct ObjectiveSense <: AbstractSolverInstanceAttribute end

@enum OptimizationSense MinSense MaxSense FeasibilitySense

Expand Down
2 changes: 1 addition & 1 deletion src/objectives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
setobjective!(m::AbstractSolverInstance, sense::OptimizationSense, func::F)
Set the objective function in the solver instance `m` to be ``f(x)`` where ``f`` is a function specified by `func` with the optimization sense (`MinSense` or `MaxSense`) specified by `sense`.
Set the objective function in the solver instance `m` to be ``f(x)`` where ``f`` is a function specified by `func` with the objective sense (`MinSense` or `MaxSense`) specified by `sense`.
"""
function setobjective! end

Expand Down
6 changes: 3 additions & 3 deletions test/contlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function linear1test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
objf = MOI.ScalarAffineFunction(v, [-1.0,0.0], 0.0)
MOI.setobjective!(m, MOI.MinSense, objf)

@test MOI.getattribute(m, MOI.Sense()) == MOI.MinSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MinSense

if MOI.cangetattribute(m, MOI.ObjectiveFunction())
@test objf MOI.getattribute(m, MOI.ObjectiveFunction())
Expand Down Expand Up @@ -93,7 +93,7 @@ function linear1test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
@test objf MOI.getattribute(m, MOI.ObjectiveFunction())
end

@test MOI.getattribute(m, MOI.Sense()) == MOI.MaxSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MaxSense

MOI.optimize!(m)

Expand Down Expand Up @@ -327,7 +327,7 @@ function linear2test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
objf = MOI.ScalarAffineFunction([x, y], [-1.0,0.0], 0.0)
MOI.setobjective!(m, MOI.MinSense, objf)

@test MOI.getattribute(m, MOI.Sense()) == MOI.MinSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MinSense

MOI.optimize!(m)

Expand Down
14 changes: 7 additions & 7 deletions test/contquadratic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function qpp0test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))

obj = MOI.ScalarQuadraticFunction(v, [0.0,0.0,0.0],[v[1], v[1], v[2], v[2], v[3]], [v[1], v[2], v[2], v[3], v[3]], [2.0, 1.0, 2.0, 1.0, 2.0], 0.0)
MOI.setobjective!(m, MOI.MinSense, obj)
@test MOI.getattribute(m, MOI.Sense()) == MOI.MinSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MinSense

if MOI.cangetattribute(m, MOI.ObjectiveFunction())
@test obj MPI.getattribute(m, MOI.ObjectiveFunction())
Expand Down Expand Up @@ -85,7 +85,7 @@ function qpp1test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))

obj = MOI.ScalarQuadraticFunction(v, [0.0,0.0,0.0],[v[1], v[1], v[1], v[2], v[2], v[3], v[3]], [v[1], v[2], v[2], v[2], v[3], v[3], v[3]], [2.0, 0.5, 0.5, 2.0, 1.0, 1.0, 1.0], 0.0)
MOI.setobjective!(m, MOI.MinSense, obj)
@test MOI.getattribute(m, MOI.Sense()) == MOI.MinSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MinSense

if MOI.cangetattribute(m, MOI.ObjectiveFunction())
@test obj MPI.getattribute(m, MOI.ObjectiveFunction())
Expand Down Expand Up @@ -116,7 +116,7 @@ function qpp1test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
# change objective to Max -2(x^2 + xy + y^2 + yz + z^2)
obj2 = MOI.ScalarQuadraticFunction(v, [0.0,0.0,0.0],[v[1], v[1], v[1], v[2], v[2], v[3], v[3]], [v[1], v[2], v[2], v[2], v[3], v[3], v[3]], [-4.0, -1.0, -1.0, -4.0, -2.0, -2.0, -2.0], 0.0)
MOI.setobjective!(m, MOI.MaxSense, obj2)
@test MOI.getattribute(m, MOI.Sense()) == MOI.MaxSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MaxSense

if MOI.cangetattribute(m, MOI.ObjectiveFunction())
@test obj2 MPI.getattribute(m, MOI.ObjectiveFunction())
Expand Down Expand Up @@ -162,7 +162,7 @@ function qpp2test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
@test MOI.getattribute(m, MOI.NumberOfConstraints{MOI.ScalarQuadraticFunction{Float64}, MOI.LessThan}()) == 1

MOI.setobjective!(m, MOI.MinSense, MOI.ScalarAffineFunction([x,y], [1.0,1.0], 0.0))
@test MOI.getattribute(m, MOI.Sense()) == MOI.MinSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MinSense

if MOI.cangetattribute(m, MOI.ConstraintFunction(), c2)
@test c2f MOI.getattribute(m, MOI.ConstraintFunction(), c2)
Expand Down Expand Up @@ -207,7 +207,7 @@ function qpd0test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
@test MOI.getattribute(m, MOI.NumberOfConstraints{MOI.ScalarQuadraticFunction{Float64}, MOI.LessThan}()) == 1

MOI.setobjective!(m, MOI.MaxSense, MOI.ScalarAffineFunction([x], [1.0], 0.0))
@test MOI.getattribute(m, MOI.Sense()) == MOI.MaxSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MaxSense

if MOI.cangetattribute(m, MOI.ConstraintFunction(), c)
@test cf MOI.getattribute(m, MOI.ConstraintFunction(), c)
Expand Down Expand Up @@ -253,7 +253,7 @@ function qpd1test(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
@test MOI.getattribute(m, MOI.NumberOfConstraints{MOI.ScalarQuadraticFunction{Float64}, MOI.LessThan}()) == 1

MOI.setobjective!(m, MOI.MinSense, MOI.ScalarAffineFunction([x], [-1.0], 0.0))
@test MOI.getattribute(m, MOI.Sense()) == MOI.MinSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MinSense

if MOI.cangetattribute(m, MOI.ConstraintFunction(), c)
@test cf MOI.getattribute(m, MOI.ConstraintFunction(), c)
Expand Down Expand Up @@ -322,7 +322,7 @@ function socptest(solver::MOI.AbstractSolver, ε=Base.rtoldefault(Float64))
@test MOI.getattribute(m, MOI.NumberOfConstraints{MOI.SingleVariable, MOI.GreaterThan}()) == 1

MOI.setobjective!(m, MOI.MinSense, MOI.ScalarAffineFunction([t], [1.0], 0.0))
@test MOI.getattribute(m, MOI.Sense()) == MOI.MinSense
@test MOI.getattribute(m, MOI.ObjectiveSense()) == MOI.MinSense

if MOI.cangetattribute(m, MOI.ConstraintFunction(), c1)
@test c1f MOI.getattribute(m, MOI.ConstraintFunction(), c1)
Expand Down

0 comments on commit 7eadf4e

Please sign in to comment.