Skip to content

Commit 5e7209e

Browse files
authored
Use MultirowChange to update vector quadratic functions in-place (#191)
* Use MultirowChange to update vector quadratic functions in-place * format with v2 * format benchmarks * fix codecov
1 parent f1abba5 commit 5e7209e

File tree

6 files changed

+211
-298
lines changed

6 files changed

+211
-298
lines changed

benchmark/run_benchmarks.jl

Lines changed: 37 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end
3737

3838
function poi_add_parameters_and_variables_alternating(N::Int)
3939
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
40-
for i in 1:Int(N / 2)
40+
for i in 1:Int(N/2)
4141
MOI.add_variable(model)
4242
MOI.add_constrained_variable(model, MOI.Parameter(1.0))
4343
end
@@ -73,13 +73,9 @@ end
7373
function poi_add_saf_variables_and_parameters_ctr(N::Int, M::Int)
7474
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
7575
x = MOI.add_variables(model, N / 2)
76-
y =
77-
first.(
78-
MOI.add_constrained_variable.(
79-
model,
80-
MOI.Parameter.(ones(Int(N / 2))),
81-
)
82-
)
76+
y = first.(
77+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
78+
)
8379
for _ in 1:M
8480
MOI.add_constraint(
8581
model,
@@ -99,13 +95,9 @@ function poi_add_saf_variables_and_parameters_ctr_parameter_update(
9995
)
10096
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
10197
x = MOI.add_variables(model, N / 2)
102-
y =
103-
first.(
104-
MOI.add_constrained_variable.(
105-
model,
106-
MOI.Parameter.(ones(Int(N / 2))),
107-
)
108-
)
98+
y = first.(
99+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
100+
)
109101
for _ in 1:M
110102
MOI.add_constraint(
111103
model,
@@ -158,13 +150,9 @@ end
158150
function poi_add_sqf_variables_parameters_ctr(N::Int, M::Int)
159151
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
160152
x = MOI.add_variables(model, N / 2)
161-
y =
162-
first.(
163-
MOI.add_constrained_variable.(
164-
model,
165-
MOI.Parameter.(ones(Int(N / 2))),
166-
)
167-
)
153+
y = first.(
154+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
155+
)
168156
for _ in 1:M
169157
MOI.add_constraint(
170158
model,
@@ -182,13 +170,9 @@ end
182170
function poi_add_sqf_variables_parameters_ctr_parameter_update(N::Int, M::Int)
183171
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
184172
x = MOI.add_variables(model, N / 2)
185-
y =
186-
first.(
187-
MOI.add_constrained_variable.(
188-
model,
189-
MOI.Parameter.(ones(Int(N / 2))),
190-
)
191-
)
173+
y = first.(
174+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
175+
)
192176
for _ in 1:M
193177
MOI.add_constraint(
194178
model,
@@ -208,13 +192,9 @@ end
208192
function poi_add_sqf_parameters_parameters_ctr(N::Int, M::Int)
209193
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
210194
x = MOI.add_variables(model, N / 2)
211-
y =
212-
first.(
213-
MOI.add_constrained_variable.(
214-
model,
215-
MOI.Parameter.(ones(Int(N / 2))),
216-
)
217-
)
195+
y = first.(
196+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
197+
)
218198
for _ in 1:M
219199
MOI.add_constraint(
220200
model,
@@ -232,13 +212,9 @@ end
232212
function poi_add_sqf_parameters_parameters_ctr_parameter_update(N::Int, M::Int)
233213
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
234214
x = MOI.add_variables(model, N / 2)
235-
y =
236-
first.(
237-
MOI.add_constrained_variable.(
238-
model,
239-
MOI.Parameter.(ones(Int(N / 2))),
240-
)
241-
)
215+
y = first.(
216+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
217+
)
242218
for _ in 1:M
243219
MOI.add_constraint(
244220
model,
@@ -284,13 +260,9 @@ end
284260
function poi_add_saf_variables_and_parameters_obj(N::Int, M::Int)
285261
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
286262
x = MOI.add_variables(model, N / 2)
287-
y =
288-
first.(
289-
MOI.add_constrained_variable.(
290-
model,
291-
MOI.Parameter.(ones(Int(N / 2))),
292-
)
293-
)
263+
y = first.(
264+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
265+
)
294266
for _ in 1:M
295267
MOI.set(
296268
model,
@@ -310,13 +282,9 @@ function poi_add_saf_variables_and_parameters_obj_parameter_update(
310282
)
311283
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
312284
x = MOI.add_variables(model, N / 2)
313-
y =
314-
first.(
315-
MOI.add_constrained_variable.(
316-
model,
317-
MOI.Parameter.(ones(Int(N / 2))),
318-
)
319-
)
285+
y = first.(
286+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
287+
)
320288
for _ in 1:M
321289
MOI.set(
322290
model,
@@ -371,13 +339,9 @@ end
371339
function poi_add_sqf_variables_parameters_obj(N::Int, M::Int)
372340
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
373341
x = MOI.add_variables(model, N / 2)
374-
y =
375-
first.(
376-
MOI.add_constrained_variable.(
377-
model,
378-
MOI.Parameter.(ones(Int(N / 2))),
379-
)
380-
)
342+
y = first.(
343+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
344+
)
381345
for _ in 1:M
382346
MOI.set(
383347
model,
@@ -395,13 +359,9 @@ end
395359
function poi_add_sqf_variables_parameters_obj_parameter_update(N::Int, M::Int)
396360
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
397361
x = MOI.add_variables(model, N / 2)
398-
y =
399-
first.(
400-
MOI.add_constrained_variable.(
401-
model,
402-
MOI.Parameter.(ones(Int(N / 2))),
403-
)
404-
)
362+
y = first.(
363+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
364+
)
405365
for _ in 1:M
406366
MOI.set(
407367
model,
@@ -423,13 +383,9 @@ end
423383
function poi_add_sqf_parameters_parameters_obj(N::Int, M::Int)
424384
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
425385
x = MOI.add_variables(model, N / 2)
426-
y =
427-
first.(
428-
MOI.add_constrained_variable.(
429-
model,
430-
MOI.Parameter.(ones(Int(N / 2))),
431-
)
432-
)
386+
y = first.(
387+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
388+
)
433389
for _ in 1:M
434390
MOI.set(
435391
model,
@@ -447,13 +403,9 @@ end
447403
function poi_add_sqf_parameters_parameters_obj_parameter_update(N::Int, M::Int)
448404
model = POI.Optimizer(MOI.Utilities.Model{Float64}())
449405
x = MOI.add_variables(model, N / 2)
450-
y =
451-
first.(
452-
MOI.add_constrained_variable.(
453-
model,
454-
MOI.Parameter.(ones(Int(N / 2))),
455-
)
456-
)
406+
y = first.(
407+
MOI.add_constrained_variable.(model, MOI.Parameter.(ones(Int(N / 2)))),
408+
)
457409
for _ in 1:M
458410
MOI.set(
459411
model,

0 commit comments

Comments
 (0)