1 | function output = calllindo_miqp(interfacedata) |
---|
2 | |
---|
3 | global MY_LICENSE_FILE |
---|
4 | lindo |
---|
5 | |
---|
6 | % Retrieve needed data |
---|
7 | options = interfacedata.options; |
---|
8 | F_struc = interfacedata.F_struc; |
---|
9 | c = interfacedata.c; |
---|
10 | K = interfacedata.K; |
---|
11 | x0 = interfacedata.x0; |
---|
12 | Q = interfacedata.Q; |
---|
13 | lb = interfacedata.lb; |
---|
14 | ub = interfacedata.ub; |
---|
15 | monomtable = interfacedata.monomtable; |
---|
16 | |
---|
17 | lindo; |
---|
18 | |
---|
19 | if ~isempty(F_struc) |
---|
20 | A = -F_struc(:,2:end); |
---|
21 | b = F_struc(:,1); |
---|
22 | csense = [repmat('E',1,K.f) repmat('L',1,K.l)]; |
---|
23 | else |
---|
24 | A = []; |
---|
25 | b = []; |
---|
26 | csense = []; |
---|
27 | |
---|
28 | A = ones(1,length(c)); |
---|
29 | b = 1e6; |
---|
30 | csense = 'L'; |
---|
31 | end |
---|
32 | |
---|
33 | % Specifying variable types... |
---|
34 | vtype = repmat('C',1,length(c)); |
---|
35 | vtype(interfacedata.integer_variables) = 'I'; |
---|
36 | |
---|
37 | % Specifying the quadratic portion of the problem data |
---|
38 | [QCvar1,QCvar2,QCcoef] = find(triu(Q)); |
---|
39 | QCrows = zeros(1,length(QCvar1)); |
---|
40 | QCvar1 = QCvar1 - 1; |
---|
41 | QCvar2 = QCvar2 - 1; |
---|
42 | |
---|
43 | % Solve the problem using the generic QP/LP/MIP/MIQP solver (lmsolvemp.m) |
---|
44 | objsen=LS_MIN; |
---|
45 | solver=eval(options.lindo.LS_METHOD); |
---|
46 | |
---|
47 | solvertime = clock; |
---|
48 | if nnz(Q)>0 |
---|
49 | [x,D_struc,s,dj,pobj,solstat,nErr] = LMsolvem(A,full(b),full(c),csense,lb,ub,vtype,QCrows-1,QCvar1,QCvar2,2*QCcoef,objsen,solver,options.verbose); |
---|
50 | else |
---|
51 | [x,D_struc,s,dj,pobj,solstat,nErr] = LMsolvem(A,full(b),full(c),csense,lb,ub,vtype,[],[],[],[],objsen,solver,options.verbose); |
---|
52 | end |
---|
53 | if interfacedata.getsolvertime solvertime = etime(clock,solvertime);else solvertime = 0;end |
---|
54 | |
---|
55 | switch solstat |
---|
56 | case {LS_STATUS_OPTIMAL,LS_STATUS_BASIC_OPTIMAL,7,8} |
---|
57 | problem = 0; |
---|
58 | case {LS_STATUS_INFEASIBLE} |
---|
59 | problem = 1; |
---|
60 | case {LS_STATUS_UNBOUNDED} |
---|
61 | problem = 2; |
---|
62 | otherwise |
---|
63 | problem = 11; |
---|
64 | end |
---|
65 | infostr = yalmiperror(problem,'LINDO-QP'); |
---|
66 | |
---|
67 | % Save all data sent to solver? |
---|
68 | if options.savesolverinput |
---|
69 | solverinput.A = A; |
---|
70 | solverinput.b = b; |
---|
71 | solverinput.c = c; |
---|
72 | solverinput.csense = csense; |
---|
73 | solverinput.vtype = vtype; |
---|
74 | solverinput.lb = lb; |
---|
75 | solverinput.vtype = vtype; |
---|
76 | solverinput.objsen = objsen; |
---|
77 | solverinput.solver = solver; |
---|
78 | solverinput.options = options.fmincon; |
---|
79 | else |
---|
80 | solverinput = []; |
---|
81 | end |
---|
82 | |
---|
83 | % Save all data from the solver? |
---|
84 | if options.savesolveroutput |
---|
85 | solveroutput.w = x; |
---|
86 | solveroutput.y = D_struc; |
---|
87 | solveroutput.s = s; |
---|
88 | solveroutput.pobj=pobj; |
---|
89 | solveroutput.solstat=solstat; |
---|
90 | solveroutput.nErr=nErr; |
---|
91 | else |
---|
92 | solveroutput = []; |
---|
93 | end |
---|
94 | |
---|
95 | % Standard interface |
---|
96 | output = createoutput(x,D_struc,[],problem,'LINDO',solverinput,solveroutput,solvertime); |
---|