@@ -200,10 +200,12 @@ end
200
200
201
201
Sets the objective sense of the model to the given sense.
202
202
203
- See [` set_objective_function`](@ref) to set the objective function.
203
+ See also: [`@objective`](@ref), [` set_objective_function`](@ref), [`set_objective`](@ref)
204
204
205
- These are low-level functions; the recommended way to set the objective is with
206
- the [`@objective`](@ref) macro.
205
+ ## FEASIBILITY_SENSE
206
+
207
+ Setting the objective sense to [`FEASIBILITY_SENSE`](@ref) will remove any
208
+ existing objective.
207
209
208
210
## Example
209
211
@@ -220,7 +222,8 @@ MAX_SENSE::OptimizationSense = 1
220
222
```
221
223
"""
222
224
function set_objective_sense (model:: GenericModel , sense:: MOI.OptimizationSense )
223
- return MOI. set (model, MOI. ObjectiveSense (), sense)
225
+ MOI. set (model, MOI. ObjectiveSense (), sense)
226
+ return
224
227
end
225
228
226
229
"""
229
232
set_objective_function(model::GenericModel, func::Real)
230
233
set_objective_function(model::GenericModel, func::Vector{<:AbstractJuMPScalar})
231
234
232
- Sets the objective function of the model to the given function.
233
-
234
- See [`set_objective_sense`](@ref) to set the objective sense.
235
+ Set the objective function of `model` to the given function `func`.
235
236
236
- These are low-level functions; the recommended way to set the objective is with
237
- the [`@objective`](@ref) macro.
237
+ See also: [`@objective`](@ref), [`set_objective_function`](@ref), [`set_objective`](@ref)
238
238
239
239
## Example
240
240
@@ -277,14 +277,16 @@ end
277
277
278
278
function set_objective_function (model:: GenericModel , func:: AbstractJuMPScalar )
279
279
check_belongs_to_model (func, model)
280
- return set_objective_function (model, moi_function (func))
280
+ set_objective_function (model, moi_function (func))
281
+ return
281
282
end
282
283
283
284
function set_objective_function (model:: GenericModel{T} , func:: Real ) where {T}
284
- return set_objective_function (
285
+ set_objective_function (
285
286
model,
286
287
MOI. ScalarAffineFunction (MOI. ScalarAffineTerm{T}[], convert (T, func)),
287
288
)
289
+ return
288
290
end
289
291
290
292
function set_objective_function (
@@ -294,7 +296,8 @@ function set_objective_function(
294
296
for f in func
295
297
check_belongs_to_model (f, model)
296
298
end
297
- return set_objective_function (model, moi_function (func))
299
+ set_objective_function (model, moi_function (func))
300
+ return
298
301
end
299
302
300
303
function set_objective_function (model:: AbstractModel , func)
@@ -306,24 +309,41 @@ end
306
309
307
310
The functional equivalent of the [`@objective`](@ref) macro.
308
311
309
- Sets the objective sense and objective function simultaneously, and is
310
- equivalent to calling [`set_objective_sense`](@ref) and
311
- [`set_objective_function`](@ref) separately.
312
+ This function sets the objective sense and objective function simultaneously,
313
+ and it is equivalent to calling [`set_objective_sense`](@ref) followed by
314
+ [`set_objective_function`](@ref).
315
+
316
+ This is a low-level function; the recommended way to set the objective function
317
+ and sense is with the [`@objective`](@ref) macro.
318
+
319
+ ## FEASIBILITY_SENSE
320
+
321
+ You should not set `sense` to [`FEASIBILITY_SENSE`](@ref) because
322
+ [`FEASIBILITY_SENSE`](@ref) implies that there is no objective function.
323
+
324
+ Instead of `set_objective(model, FEASIBILITY_SENSE, f)`, do
325
+ `set_objective_sense(model, FEASIBILITY_SENSE)`.
312
326
313
327
## Example
314
328
315
329
```jldoctest
316
330
julia> model = Model();
317
331
318
- julia> @variable(model, x)
319
- x
332
+ julia> @variable(model, x);
320
333
321
334
julia> set_objective(model, MIN_SENSE, x)
335
+
336
+ julia> objective_sense(model)
337
+ MIN_SENSE::OptimizationSense = 0
338
+
339
+ julia> objective_function(model)
340
+ x
322
341
```
323
342
"""
324
343
function set_objective (model:: AbstractModel , sense:: MOI.OptimizationSense , func)
325
344
set_objective_sense (model, sense)
326
- return set_objective_function (model, func)
345
+ set_objective_function (model, func)
346
+ return
327
347
end
328
348
329
349
"""
0 commit comments