-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolveDP.m
32 lines (28 loc) · 934 Bytes
/
solveDP.m
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
function [v, d, beta] = solveDP(t, Bundle, Alphas, tol, round)
dimensionOfBeta = length(Alphas);
A = [];
b = [];
Aeq = ones(1,dimensionOfBeta);
beq = 1;
lb = zeros(dimensionOfBeta,1);
ub = Inf(dimensionOfBeta,1);
%Start Value
startValue = repmat(1/dimensionOfBeta,dimensionOfBeta,1);
options = optimoptions('fmincon','Algorithm','active-set', 'TolCon', tol, 'TolFun', tol, 'Display', 'off');
beta = fmincon(@QP_Problem, startValue, A, b, Aeq, beq, lb, ub, [], options);
if round
beta = max (beta,0);
if sum(beta)>0
beta = beta / sum(beta);
end
end
%Convert to solution of DP
sBeta = Bundle * beta;
d = -t*sBeta;
v = -t*dot(sBeta,sBeta) - Alphas*beta;
function value = QP_Problem(beta)
vector = Bundle*beta;
barrier = Alphas*beta/t;
value = 0.5* dot(vector,vector) + barrier;
end
end