-
Notifications
You must be signed in to change notification settings - Fork 28
/
msk_functions.jl
8826 lines (7767 loc) · 334 KB
/
msk_functions.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Contents of this file is generated. Do not edit by hand!
# MOSEK 9.0.90
export
analyzenames,
analyzeproblem,
analyzesolution,
appendbarvars,
appendcone,
appendconeseq,
appendconesseq,
appendcons,
appendsparsesymmat,
appendsparsesymmatlist,
appendvars,
basiscond,
bktostr,
callbackcodetostr,
checkinall,
checkinlicense,
checkmem,
checkoutlicense,
chgconbound,
chgvarbound,
commitchanges,
conetypetostr,
deletesolution,
dualsensitivity,
echointro,
generateconenames,
generateconnames,
generatevarnames,
getacol,
getacolnumnz,
getacolslice,
getacolslicenumnz,
getacolslicetrip,
getaij,
getapiecenumnz,
getarow,
getarownumnz,
getarowslice,
getarowslicenumnz,
getarowslicetrip,
getatruncatetol,
getbarablocktriplet,
getbaraidx,
getbaraidxij,
getbaraidxinfo,
getbarasparsity,
getbarcblocktriplet,
getbarcidx,
getbarcidxinfo,
getbarcidxj,
getbarcsparsity,
getbarsj,
getbarsslice,
getbarvarname,
getbarvarnameindex,
getbarvarnamelen,
getbarxj,
getbarxslice,
getc,
getcfix,
getcj,
getclist,
getcodedesc,
getconbound,
getconboundslice,
getcone,
getconeinfo,
getconename,
getconenameindex,
getconenamelen,
getconname,
getconnameindex,
getconnamelen,
getcslice,
getdimbarvarj,
getdouinf,
getdouparam,
getdualobj,
getdualsolutionnorms,
getdviolbarvar,
getdviolcon,
getdviolcones,
getdviolvar,
getinfeasiblesubproblem,
getinfname,
getintinf,
getintparam,
getlenbarvarj,
getlintinf,
getmaxnumanz,
getmaxnumbarvar,
getmaxnumcon,
getmaxnumcone,
getmaxnumqnz,
getmaxnumvar,
getmemusage,
getnadouinf,
getnadouparam,
getnaintinf,
getnaintparam,
getnastrparam,
getnumanz,
getnumanz64,
getnumbarablocktriplets,
getnumbaranz,
getnumbarcblocktriplets,
getnumbarcnz,
getnumbarvar,
getnumcon,
getnumcone,
getnumconemem,
getnumintvar,
getnumparam,
getnumqconknz,
getnumqobjnz,
getnumsymmat,
getnumvar,
getobjname,
getobjnamelen,
getobjsense,
getparamname,
getprimalobj,
getprimalsolutionnorms,
getprobtype,
getprosta,
getpviolbarvar,
getpviolcon,
getpviolcones,
getpviolvar,
getqconk,
getqobj,
getqobjij,
getreducedcosts,
getskc,
getskcslice,
getskn,
getskx,
getskxslice,
getslc,
getslcslice,
getslx,
getslxslice,
getsnx,
getsnxslice,
getsolsta,
getsolution,
getsolutioninfo,
getsolutionslice,
getsparsesymmat,
getstrparam,
getstrparamlen,
getsuc,
getsucslice,
getsux,
getsuxslice,
getsymmatinfo,
gettaskname,
gettasknamelen,
getvarbound,
getvarboundslice,
getvarname,
getvarnameindex,
getvarnamelen,
getvartype,
getvartypelist,
getversion,
getxc,
getxcslice,
getxx,
getxxslice,
gety,
getyslice,
initbasissolve,
inputdata,
isdouparname,
isintparname,
isstrparname,
licensecleanup,
linkfiletostream,
onesolutionsummary,
optimize,
optimizermt,
optimizersummary,
primalrepair,
primalsensitivity,
printparam,
putacol,
putacollist,
putacolslice,
putaij,
putaijlist,
putarow,
putarowlist,
putarowslice,
putatruncatetol,
putbarablocktriplet,
putbaraij,
putbaraijlist,
putbararowlist,
putbarcblocktriplet,
putbarcj,
putbarsj,
putbarvarname,
putbarxj,
putcfix,
putcj,
putclist,
putconbound,
putconboundlist,
putconboundlistconst,
putconboundslice,
putconboundsliceconst,
putcone,
putconename,
putconname,
putconsolutioni,
putcslice,
putdouparam,
putintparam,
putlicensecode,
putlicensedebug,
putlicensepath,
putlicensewait,
putmaxnumanz,
putmaxnumbarvar,
putmaxnumcon,
putmaxnumcone,
putmaxnumqnz,
putmaxnumvar,
putnadouparam,
putnaintparam,
putnastrparam,
putobjname,
putobjsense,
putparam,
putqcon,
putqconk,
putqobj,
putqobjij,
putskc,
putskcslice,
putskx,
putskxslice,
putslc,
putslcslice,
putslx,
putslxslice,
putsnx,
putsnxslice,
putsolution,
putsolutionyi,
putstrparam,
putsuc,
putsucslice,
putsux,
putsuxslice,
puttaskname,
putvarbound,
putvarboundlist,
putvarboundlistconst,
putvarboundslice,
putvarboundsliceconst,
putvarname,
putvarsolutionj,
putvartype,
putvartypelist,
putxc,
putxcslice,
putxx,
putxxslice,
puty,
putyslice,
readdata,
readdataformat,
readjsonstring,
readlpstring,
readopfstring,
readparamfile,
readptfstring,
readsolution,
readsummary,
readtask,
removebarvars,
removecones,
removecons,
removevars,
resizetask,
sensitivityreport,
setdefaults,
setupthreads,
solutiondef,
solutionsummary,
solvewithbasis,
strtoconetype,
strtosk,
updatesolutioninfo,
writedata,
writejsonsol,
writeparamfile,
writesolution,
writetask
"""
analyzenames(task_:: MSKtask,whichstream_:: Streamtype,nametype_:: Nametype)
* `task :: MSKtask`. An optimization task.
* `whichstream :: Streamtype`. Index of the stream.
* `nametype :: Nametype`. The type of names e.g. valid in MPS or LP files.
The function analyzes the names and issues an error if a name is invalid.
"""
function analyzenames end
function analyzenames(task_:: MSKtask,whichstream_:: Streamtype,nametype_:: Nametype)
res = disable_sigint() do
@msk_ccall( "analyzenames",Int32,(Ptr{Nothing},Int32,Int32,),task_.task,whichstream_.value,nametype_.value)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
analyzeproblem(task_:: MSKtask,whichstream_:: Streamtype)
* `task :: MSKtask`. An optimization task.
* `whichstream :: Streamtype`. Index of the stream.
The function analyzes the data of a task and writes out a report.
"""
function analyzeproblem end
function analyzeproblem(task_:: MSKtask,whichstream_:: Streamtype)
res = disable_sigint() do
@msk_ccall( "analyzeproblem",Int32,(Ptr{Nothing},Int32,),task_.task,whichstream_.value)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
analyzesolution(task_:: MSKtask,whichstream_:: Streamtype,whichsol_:: Soltype)
* `task :: MSKtask`. An optimization task.
* `whichstream :: Streamtype`. Index of the stream.
* `whichsol :: Soltype`. Selects a solution.
Print information related to the quality of the solution and
other solution statistics.
By default this function prints information about the
largest infeasibilites in the solution, the primal (and
possibly dual) objective value and the solution status.
Following parameters can be used to configure the printed statistics:
* `MSK_IPAR_ANA_SOL_BASIS`` enables or disables printing of statistics specific to the basis solution (condition number, number of basic variables etc.). Default is on.
* `MSK_IPAR_ANA_SOL_PRINT_VIOLATED`` enables or disables listing names of all constraints (both primal and dual) which are violated by the solution. Default is off.
* `MSK_DPAR_ANA_SOL_INFEAS_TOL`` is the tolerance defining when a constraint is considered violated. If a constraint is violated more than this, it will be listed in the summary.
"""
function analyzesolution end
function analyzesolution(task_:: MSKtask,whichstream_:: Streamtype,whichsol_:: Soltype)
res = disable_sigint() do
@msk_ccall( "analyzesolution",Int32,(Ptr{Nothing},Int32,Int32,),task_.task,whichstream_.value,whichsol_.value)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
appendbarvars{T1}(task:: MSKtask,dim:: Vector{T1})
appendbarvars(task_:: MSKtask,dim_:: Vector{Int32})
* `task :: MSKtask`. An optimization task.
* `dim :: Vector{Int32}`. Dimensions of symmetric matrix variables to be added.
Appends positive semidefinite matrix variables of dimensions given by `dim` to the problem.
"""
function appendbarvars end
appendbarvars(task:: MSKtask,dim:: Vector{T1}) where {T1} = appendbarvars(task,convert(Vector{Int32},dim))
function appendbarvars(task_:: MSKtask,dim_:: Vector{Int32})
num_ = minimum([ length(dim_) ])
res = disable_sigint() do
@msk_ccall( "appendbarvars",Int32,(Ptr{Nothing},Int32,Ptr{Int32},),task_.task,num_,dim_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
appendcone{T2,T3}(task:: MSKtask,ct:: Conetype,conepar:: T2,submem:: Vector{T3})
appendcone(task_:: MSKtask,ct_:: Conetype,conepar_:: Float64,submem_:: Vector{Int32})
* `task :: MSKtask`. An optimization task.
* `ct :: Conetype`. Specifies the type of the cone.
* `conepar :: Float64`. For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0.
* `submem :: Vector{Int32}`. Variable subscripts of the members in the cone.
Appends a new conic constraint to the problem. Hence, add a constraint
```math
\\hat{x} \\in \\mathcal{K}
```
to the problem, where ``\\mathcal{K}`` is a convex cone. ``\\hat{x}`` is a
subset of the variables which will be specified by the argument
`submem`. Cone type is specified by `ct`.
Define
```math
\\hat{x} = x_{\\mathtt{submem}[0]},\\ldots,x_{\\mathtt{submem}[\\mathtt{nummem}-1]}.
```
Depending on the value of `ct` this function appends one of the constraints:
* Quadratic cone (`MSK_CT_QUAD`, requires ``\\mathtt{nummem}\\geq 1``):
```math
\\hat{x}_0 \\geq \\sqrt{\\sum_{i=1}^{i<\\mathtt{nummem}} \\hat{x}_i^2}
```
* Rotated quadratic cone (`MSK_CT_RQUAD`, requires ``\\mathtt{nummem}\\geq 2``):
```math
2 \\hat{x}_0 \\hat{x}_1 \\geq \\sum_{i=2}^{i<\\mathtt{nummem}} \\hat{x}^2_i, \\mathcal{C}_q \\hat{x}_{0}, \\hat{x}_1 \\geq 0
```
* Primal exponential cone (`MSK_CT_PEXP`, requires ``\\mathtt{nummem}=3``):
```math
\\hat{x}_0 \\geq \\hat{x}_1\\exp(\\hat{x}_2/\\hat{x}_1), \\mathcal{C}_q \\hat{x}_0,\\hat{x}_1 \\geq 0
```
* Primal power cone (`MSK_CT_PPOW`, requires ``\\mathtt{nummem}\\geq 2``):
```math
\\hat{x}_0^\\alpha \\hat{x}_1^{1-\\alpha} \\geq \\sqrt{\\sum_{i=2}^{i<\\mathtt{nummem}} \\hat{x}^2_i}, \\mathcal{C}_q \\hat{x}_{0}, \\hat{x}_1 \\geq 0
```
where ``\\alpha`` is the cone parameter specified by `conepar`.
* Dual exponential cone (`MSK_CT_DEXP`, requires ``\\mathtt{nummem}=3``):
```math
\\hat{x}_0 \\geq -\\hat{x}_2 e^{-1}\\exp(\\hat{x}_1/\\hat{x}_2), \\mathcal{C}_q \\hat{x}_2\\leq 0,\\hat{x}_0 \\geq 0
```
* Dual power cone (`MSK_CT_DPOW`, requires ``\\mathtt{nummem}\\geq 2``):
```math
\\left(\\frac{\\hat{x}_0}{\\alpha}\\right)^\\alpha \\left(\\frac{\\hat{x}_1}{1-\\alpha}\\right)^{1-\\alpha} \\geq \\sqrt{\\sum_{i=2}^{i<\\mathtt{nummem}} \\hat{x}^2_i}, \\mathcal{C}_q \\hat{x}_{0}, \\hat{x}_1 \\geq 0
```
where ``\\alpha`` is the cone parameter specified by `conepar`.
* Zero cone (`MSK_CT_ZERO`):
```math
\\hat{x}_i = 0 \\ \\textrm{for all}\\ i
```
Please note that the sets of variables appearing in different conic constraints must be disjoint.
For an explained code example see :numref:`doc.tutorial_cqo`, :numref:`doc.tutorial_ceo` or :numref:`doc.tutorial_pow`.
"""
function appendcone end
appendcone(task:: MSKtask,ct:: Conetype,conepar:: T2,submem:: Vector{T3}) where {T2,T3} = appendcone(task,ct,convert(Float64,conepar),convert(Vector{Int32},submem))
function appendcone(task_:: MSKtask,ct_:: Conetype,conepar_:: Float64,submem_:: Vector{Int32})
nummem_ = minimum([ length(submem_) ])
res = disable_sigint() do
@msk_ccall( "appendcone",Int32,(Ptr{Nothing},Int32,Float64,Int32,Ptr{Int32},),task_.task,ct_.value,conepar_,nummem_,submem_ .- Int32(1))
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
appendconeseq{T2,T3,T4}(task:: MSKtask,ct:: Conetype,conepar:: T2,nummem:: T3,j:: T4)
appendconeseq(task_:: MSKtask,ct_:: Conetype,conepar_:: Float64,nummem_:: Int32,j_:: Int32)
* `task :: MSKtask`. An optimization task.
* `ct :: Conetype`. Specifies the type of the cone.
* `conepar :: Float64`. For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0.
* `nummem :: Int32`. Number of member variables in the cone.
* `j :: Int32`. Index of the first variable in the conic constraint.
Appends a new conic constraint to the problem, as in `Mosek.appendcone`. The
function assumes the members of cone are sequential
where the first member has index `j` and the last
`j+nummem-1`.
"""
function appendconeseq end
appendconeseq(task:: MSKtask,ct:: Conetype,conepar:: T2,nummem:: T3,j:: T4) where {T2,T3,T4} = appendconeseq(task,ct,convert(Float64,conepar),convert(Int32,nummem),convert(Int32,j))
function appendconeseq(task_:: MSKtask,ct_:: Conetype,conepar_:: Float64,nummem_:: Int32,j_:: Int32)
res = disable_sigint() do
@msk_ccall( "appendconeseq",Int32,(Ptr{Nothing},Int32,Float64,Int32,Int32,),task_.task,ct_.value,conepar_,nummem_,j_-1)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
appendconesseq{T2,T3,T4}(task:: MSKtask,ct:: Vector{Conetype},conepar:: Vector{T2},nummem:: Vector{T3},j:: T4)
appendconesseq(task_:: MSKtask,ct_:: Vector{Conetype},conepar_:: Vector{Float64},nummem_:: Vector{Int32},j_:: Int32)
* `task :: MSKtask`. An optimization task.
* `ct :: Vector{Int32}`. Specifies the type of the cone.
* `conepar :: Vector{Float64}`. For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0.
* `nummem :: Vector{Int32}`. Numbers of member variables in the cones.
* `j :: Int32`. Index of the first variable in the first cone to be appended.
Appends a number of conic constraints to the problem, as in `Mosek.appendcone`.
The ``k`` th cone is assumed to be of dimension `nummem[k]`. Moreover, it is assumed
that the first variable of the first cone has index ``j`` and starting from there the
sequentially following variables belong to the first cone, then to the second cone and so on.
"""
function appendconesseq end
appendconesseq(task:: MSKtask,ct:: Vector{Conetype},conepar:: Vector{T2},nummem:: Vector{T3},j:: T4) where {T2,T3,T4} = appendconesseq(task,ct,convert(Vector{Float64},conepar),convert(Vector{Int32},nummem),convert(Int32,j))
function appendconesseq(task_:: MSKtask,ct_:: Vector{Conetype},conepar_:: Vector{Float64},nummem_:: Vector{Int32},j_:: Int32)
ct_i32 = Int32[item.value for item in ct_]
num_ = minimum([ length(ct_),length(conepar_),length(nummem_) ])
res = disable_sigint() do
@msk_ccall( "appendconesseq",Int32,(Ptr{Nothing},Int32,Ptr{Int32},Ptr{Float64},Ptr{Int32},Int32,),task_.task,num_,ct_,conepar_,nummem_,j_-1)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
appendcons{T1}(task:: MSKtask,num:: T1)
appendcons(task_:: MSKtask,num_:: Int32)
* `task :: MSKtask`. An optimization task.
* `num :: Int32`. Number of constraints which should be appended.
Appends a number of constraints to the
model. Appended constraints will be declared
free. Please note that MOSEK will automatically
expand the problem dimension to accommodate the
additional constraints.
"""
function appendcons end
appendcons(task:: MSKtask,num:: T1) where {T1} = appendcons(task,convert(Int32,num))
function appendcons(task_:: MSKtask,num_:: Int32)
res = disable_sigint() do
@msk_ccall( "appendcons",Int32,(Ptr{Nothing},Int32,),task_.task,num_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
idx = appendsparsesymmat{T1,T2,T3,T4}(task:: MSKtask,dim:: T1,subi:: Vector{T2},subj:: Vector{T3},valij:: Vector{T4})
idx = appendsparsesymmat(task_:: MSKtask,dim_:: Int32,subi_:: Vector{Int32},subj_:: Vector{Int32},valij_:: Vector{Float64})
* `task :: MSKtask`. An optimization task.
* `dim :: Int32`. Dimension of the symmetric matrix that is appended.
* `subi :: Vector{Int32}`. Row subscript in the triplets.
* `subj :: Vector{Int32}`. Column subscripts in the triplets.
* `valij :: Vector{Float64}`. Values of each triplet.
* `idx :: Int64`. Unique index assigned to the inputted matrix.
MOSEK maintains a storage of symmetric data matrices that is used to build
``\\bar C`` and ``\\bar A``. The storage can be thought of as a vector of
symmetric matrices denoted ``E``. Hence, ``E_i`` is a symmetric matrix of certain
dimension.
This function appends a general sparse symmetric matrix on triplet form to the
vector ``E`` of symmetric matrices. The vectors `subi`, `subj`, and
`valij` contains the row subscripts, column subscripts and values of each
element in the symmetric matrix to be appended. Since the matrix that is
appended is symmetric, only the lower triangular part should be specified.
Moreover, duplicates are not allowed.
Observe the function reports the index (position) of the appended matrix in
``E``. This index should be used for later references to the appended matrix.
"""
function appendsparsesymmat end
appendsparsesymmat(task:: MSKtask,dim:: T1,subi:: Vector{T2},subj:: Vector{T3},valij:: Vector{T4}) where {T1,T2,T3,T4} = appendsparsesymmat(task,convert(Int32,dim),convert(Vector{Int32},subi),convert(Vector{Int32},subj),convert(Vector{Float64},valij))
function appendsparsesymmat(task_:: MSKtask,dim_:: Int32,subi_:: Vector{Int32},subj_:: Vector{Int32},valij_:: Vector{Float64})
idx_ = Vector{Int64}(undef,1)
nz_ = minimum([ length(subi_),length(subj_),length(valij_) ])
res = disable_sigint() do
@msk_ccall( "appendsparsesymmat",Int32,(Ptr{Nothing},Int32,Int64,Ptr{Int32},Ptr{Int32},Ptr{Float64},Ptr{Int64},),task_.task,dim_,nz_,subi_ .- Int32(1),subj_ .- Int32(1),valij_,idx_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
(convert(Int64,idx_[1]+1))
end
"""
idx = appendsparsesymmatlist{T1,T2,T3,T4,T5}(task:: MSKtask,dims:: Vector{T1},nz:: Vector{T2},subi:: Vector{T3},subj:: Vector{T4},valij:: Vector{T5})
idx = appendsparsesymmatlist(task_:: MSKtask,dims_:: Vector{Int32},nz_:: Vector{Int64},subi_:: Vector{Int32},subj_:: Vector{Int32},valij_:: Vector{Float64})
* `task :: MSKtask`. An optimization task.
* `dims :: Vector{Int32}`. Dimensions of the symmetric matrixes.
* `nz :: Vector{Int64}`. Number of nonzeros for each matrix.
* `subi :: Vector{Int32}`. Row subscript in the triplets.
* `subj :: Vector{Int32}`. Column subscripts in the triplets.
* `valij :: Vector{Float64}`. Values of each triplet.
* `idx :: Vector{Int64}`. Unique index assigned to the inputted matrix.
MOSEK maintains a storage of symmetric data matrices that is used to build
``\\bar C`` and ``\\bar A``. The storage can be thought of as a vector of
symmetric matrices denoted ``E``. Hence, ``E_i`` is a symmetric matrix of certain
dimension.
This function appends general sparse symmetric matrixes on triplet form to the
vector ``E`` of symmetric matrices. The vectors `subi`, `subj`, and
`valij` contains the row subscripts, column subscripts and values of each
element in the symmetric matrix to be appended. Since the matrix that is
appended is symmetric, only the lower triangular part should be specified.
Moreover, duplicates are not allowed.
Observe the function reports the index (position) of the appended matrix in
``E``. This index should be used for later references to the appended matrix.
"""
function appendsparsesymmatlist end
appendsparsesymmatlist(task:: MSKtask,dims:: Vector{T1},nz:: Vector{T2},subi:: Vector{T3},subj:: Vector{T4},valij:: Vector{T5}) where {T1,T2,T3,T4,T5} = appendsparsesymmatlist(task,convert(Vector{Int32},dims),convert(Vector{Int64},nz),convert(Vector{Int32},subi),convert(Vector{Int32},subj),convert(Vector{Float64},valij))
function appendsparsesymmatlist(task_:: MSKtask,dims_:: Vector{Int32},nz_:: Vector{Int64},subi_:: Vector{Int32},subj_:: Vector{Int32},valij_:: Vector{Float64})
num_ = minimum([ length(dims_),length(nz_) ])
__tmp_var_0 = sum((nz_))
if length(subi_) < __tmp_var_0
println("Array argument subi is not long enough")
throw(BoundsError())
end
__tmp_var_1 = sum((nz_))
if length(subj_) < __tmp_var_1
println("Array argument subj is not long enough")
throw(BoundsError())
end
__tmp_var_2 = sum((nz_))
if length(valij_) < __tmp_var_2
println("Array argument valij is not long enough")
throw(BoundsError())
end
__tmp_var_3 = (num_)
__tmp_var_4 = zeros(Int64,__tmp_var_3)
idx_ = __tmp_var_4
res = disable_sigint() do
@msk_ccall( "appendsparsesymmatlist",Int32,(Ptr{Nothing},Int32,Ptr{Int32},Ptr{Int64},Ptr{Int32},Ptr{Int32},Ptr{Float64},Ptr{Int64},),task_.task,num_,dims_,nz_,subi_ .- Int32(1),subj_ .- Int32(1),valij_,__tmp_var_4)
end
__tmp_var_4 .+= 1
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
(__tmp_var_4)
end
"""
appendvars{T1}(task:: MSKtask,num:: T1)
appendvars(task_:: MSKtask,num_:: Int32)
* `task :: MSKtask`. An optimization task.
* `num :: Int32`. Number of variables which should be appended.
Appends a number of variables to the model. Appended
variables will be fixed at zero. Please note that
MOSEK will automatically expand the problem
dimension to accommodate the additional variables.
"""
function appendvars end
appendvars(task:: MSKtask,num:: T1) where {T1} = appendvars(task,convert(Int32,num))
function appendvars(task_:: MSKtask,num_:: Int32)
res = disable_sigint() do
@msk_ccall( "appendvars",Int32,(Ptr{Nothing},Int32,),task_.task,num_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
(nrmbasis,nrminvbasis) = basiscond(task_:: MSKtask)
* `task :: MSKtask`. An optimization task.
* `nrmbasis :: Float64`. An estimate for the 1-norm of the basis.
* `nrminvbasis :: Float64`. An estimate for the 1-norm of the inverse of the basis.
If a basic solution is available and it defines a nonsingular basis, then
this function computes the 1-norm estimate of the basis matrix and a 1-norm estimate
for the inverse of the basis matrix. The 1-norm estimates are computed using the method
outlined in :cite:`STEWART:98:A`, pp. 388-391.
By definition the 1-norm condition number of a matrix ``B`` is defined as
```math
\\kappa_1(B) := \\|B\\|_1 \\|B^{-1}\\|_1.
```
Moreover, the larger the condition number is the harder it is to solve
linear equation systems involving ``B``. Given estimates for
``\\|B\\|_1`` and ``\\|B^{-1}\\|_1`` it is also possible to
estimate ``\\kappa_1(B)``.
"""
function basiscond end
function basiscond(task_:: MSKtask)
nrmbasis_ = Vector{Float64}(undef,1)
nrminvbasis_ = Vector{Float64}(undef,1)
res = disable_sigint() do
@msk_ccall( "basiscond",Int32,(Ptr{Nothing},Ptr{Float64},Ptr{Float64},),task_.task,nrmbasis_,nrminvbasis_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
(convert(Float64,nrmbasis_[1]),convert(Float64,nrminvbasis_[1]))
end
"""
str = bktostr(task_:: MSKtask,bk_:: Boundkey)
* `task :: MSKtask`. An optimization task.
* `bk :: Boundkey`. Bound key.
* `str :: AbstractString`. String corresponding to the bound key.
Obtains an identifier string corresponding to a bound key.
"""
function bktostr end
function bktostr(task_:: MSKtask,bk_:: Boundkey)
str_ = zeros(UInt8,MSK_MAX_STR_LEN+1)
res = disable_sigint() do
@msk_ccall( "bktostr",Int32,(Ptr{Nothing},Int32,Ptr{UInt8},),task_.task,bk_.value,str_)
end
str_str = String(str_)
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
(str_str[1:findfirst(isequal('\0'),str_str)-1])
end
"""
callbackcodestr = callbackcodetostr(code_:: Callbackcode)
* `code :: Callbackcode`. A callback code.
* `callbackcodestr :: AbstractString`. String corresponding to the callback code.
Obtains the string representation of a callback code.
"""
function callbackcodetostr end
function callbackcodetostr(code_:: Callbackcode)
callbackcodestr_ = zeros(UInt8,MSK_MAX_STR_LEN+1)
res = disable_sigint() do
@msk_ccall( "callbackcodetostr",Int32,(Int32,Ptr{UInt8},),code_.value,callbackcodestr_)
end
callbackcodestr_str = String(callbackcodestr_)
if res != MSK_RES_OK.value
throw(MosekError(res,""))
end
(callbackcodestr_str[1:findfirst(isequal('\0'),callbackcodestr_str)-1])
end
"""
checkinall(env_:: MSKenv)
* `env :: MSKenv`. The MOSEK environment.
Check in all unused license features to the license token server.
"""
function checkinall end
function checkinall(env_:: MSKenv)
res = disable_sigint() do
@msk_ccall( "checkinall",Int32,(Ptr{Nothing},),env_.env)
end
if res != MSK_RES_OK.value
throw(MosekError(res,""))
end
end
"""
checkinlicense(env_:: MSKenv,feature_:: Feature)
* `env :: MSKenv`. The MOSEK environment.
* `feature :: Feature`. Feature to check in to the license system.
Check in a license feature to the license server. By default all licenses
consumed by functions using a single environment are kept checked out for the
lifetime of the MOSEK environment. This function checks in a given license
feature back to the license server immediately.
If the given license feature is not checked out at all, or it is in use by a call to
`Mosek.optimize`, calling this function has no effect.
Please note that returning a license to the license server incurs a small
overhead, so frequent calls to this function should be avoided.
"""
function checkinlicense end
function checkinlicense(env_:: MSKenv,feature_:: Feature)
res = disable_sigint() do
@msk_ccall( "checkinlicense",Int32,(Ptr{Nothing},Int32,),env_.env,feature_.value)
end
if res != MSK_RES_OK.value
throw(MosekError(res,""))
end
end
"""
checkmem{T2}(task:: MSKtask,file:: AbstractString,line:: T2)
checkmem(task_:: MSKtask,file_:: AbstractString,line_:: Int32)
* `task :: MSKtask`. An optimization task.
* `file :: String`. File from which the function is called.
* `line :: Int32`. Line in the file from which the function is called.
Checks the memory allocated by the task.
"""
function checkmem end
checkmem(task:: MSKtask,file:: AbstractString,line:: T2) where {T2} = checkmem(task,file,convert(Int32,line))
function checkmem(task_:: MSKtask,file_:: AbstractString,line_:: Int32)
res = disable_sigint() do
@msk_ccall( "checkmemtask",Int32,(Ptr{Nothing},Ptr{UInt8},Int32,),task_.task,string(file_),line_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
checkoutlicense(env_:: MSKenv,feature_:: Feature)
* `env :: MSKenv`. The MOSEK environment.
* `feature :: Feature`. Feature to check out from the license system.
Checks out a license feature from the license server. Normally the required
license features will be automatically checked out the first time they are needed
by the function `Mosek.optimize`. This function can be used to check out one
or more features ahead of time.
The feature will remain checked out until the environment is deleted or the function
`Mosek.checkinlicense` is called.
If a given feature is already checked out when this function is called, the call has no effect.
"""
function checkoutlicense end
function checkoutlicense(env_:: MSKenv,feature_:: Feature)
res = disable_sigint() do
@msk_ccall( "checkoutlicense",Int32,(Ptr{Nothing},Int32,),env_.env,feature_.value)
end
if res != MSK_RES_OK.value
throw(MosekError(res,""))
end
end
"""
chgconbound{T1,T2,T3,T4}(task:: MSKtask,i:: T1,lower:: T2,finite:: T3,value:: T4)
chgconbound(task_:: MSKtask,i_:: Int32,lower_:: Int32,finite_:: Int32,value_:: Float64)
* `task :: MSKtask`. An optimization task.
* `i :: Int32`. Index of the constraint for which the bounds should be changed.
* `lower :: Int32`. If non-zero, then the lower bound is changed, otherwise the upper bound is changed.
* `finite :: Int32`. If non-zero, then the given value is assumed to be finite.
* `value :: Float64`. New value for the bound.
Changes a bound for one constraint.
If `lower` is non-zero, then the lower bound is changed as follows:
```math
\\mbox{new lower bound} =
\\left\\{
\\begin{array}{ll}
- \\infty, & \\mathtt{finite}=0, \\\\
\\mathtt{value} & \\mbox{otherwise}.
\\end{array}
\\right.
```
Otherwise if `lower` is zero, then
```math
\\mbox{new upper bound} =
\\left\\{
\\begin{array}{ll}
\\infty, & \\mathtt{finite}=0, \\\\
\\mathtt{value} & \\mbox{otherwise}.
\\end{array}
\\right.
```
Please note that this function automatically updates the bound key for the
bound, in particular, if the lower and upper bounds are identical, the
bound key is changed to `fixed`.
"""
function chgconbound end
chgconbound(task:: MSKtask,i:: T1,lower:: T2,finite:: T3,value:: T4) where {T1,T2,T3,T4} = chgconbound(task,convert(Int32,i),convert(Int32,lower),convert(Int32,finite),convert(Float64,value))
function chgconbound(task_:: MSKtask,i_:: Int32,lower_:: Int32,finite_:: Int32,value_:: Float64)
res = disable_sigint() do
@msk_ccall( "chgconbound",Int32,(Ptr{Nothing},Int32,Int32,Int32,Float64,),task_.task,i_-1,lower_,finite_,value_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
chgvarbound{T1,T2,T3,T4}(task:: MSKtask,j:: T1,lower:: T2,finite:: T3,value:: T4)
chgvarbound(task_:: MSKtask,j_:: Int32,lower_:: Int32,finite_:: Int32,value_:: Float64)
* `task :: MSKtask`. An optimization task.
* `j :: Int32`. Index of the variable for which the bounds should be changed.
* `lower :: Int32`. If non-zero, then the lower bound is changed, otherwise the upper bound is changed.
* `finite :: Int32`. If non-zero, then the given value is assumed to be finite.
* `value :: Float64`. New value for the bound.
Changes a bound for one variable.
If `lower` is non-zero, then the lower bound is changed as follows:
```math
\\mbox{new lower bound} =
\\left\\{
\\begin{array}{ll}
- \\infty, & \\mathtt{finite}=0, \\\\
\\mathtt{value} & \\mbox{otherwise}.
\\end{array}
\\right.
```
Otherwise if `lower` is zero, then
```math
\\mbox{new upper bound} =
\\left\\{
\\begin{array}{ll}
\\infty, & \\mathtt{finite}=0, \\\\
\\mathtt{value} & \\mbox{otherwise}.
\\end{array}
\\right.
```
Please note that this function automatically updates the bound key for the bound,
in particular, if the lower and upper bounds are identical, the bound key is
changed to `fixed`.
"""
function chgvarbound end
chgvarbound(task:: MSKtask,j:: T1,lower:: T2,finite:: T3,value:: T4) where {T1,T2,T3,T4} = chgvarbound(task,convert(Int32,j),convert(Int32,lower),convert(Int32,finite),convert(Float64,value))
function chgvarbound(task_:: MSKtask,j_:: Int32,lower_:: Int32,finite_:: Int32,value_:: Float64)
res = disable_sigint() do
@msk_ccall( "chgvarbound",Int32,(Ptr{Nothing},Int32,Int32,Int32,Float64,),task_.task,j_-1,lower_,finite_,value_)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
commitchanges(task_:: MSKtask)
* `task :: MSKtask`. An optimization task.
Commits all cached problem changes to the task. It is usually not necessary to call this function explicitly since changes will be committed automatically when required.
"""
function commitchanges end
function commitchanges(task_:: MSKtask)
res = disable_sigint() do
@msk_ccall( "commitchanges",Int32,(Ptr{Nothing},),task_.task)
end
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
end
"""
str = conetypetostr(task_:: MSKtask,ct_:: Conetype)
* `task :: MSKtask`. An optimization task.
* `ct :: Conetype`. Specifies the type of the cone.
* `str :: AbstractString`. String corresponding to the cone type.
Obtains the cone string identifier corresponding to a cone type.
"""
function conetypetostr end
function conetypetostr(task_:: MSKtask,ct_:: Conetype)
str_ = zeros(UInt8,1024+1)
res = disable_sigint() do
@msk_ccall( "conetypetostr",Int32,(Ptr{Nothing},Int32,Ptr{UInt8},),task_.task,ct_.value,str_)
end
str_str = String(str_)
if res != MSK_RES_OK.value
msg = getlasterror(task_)
throw(MosekError(res,msg))
end
(str_str[1:findfirst(isequal('\0'),str_str)-1])
end
"""
deletesolution(task_:: MSKtask,whichsol_:: Soltype)