Commit 2d113cd0 authored by Davis King's avatar Davis King

Made alpha initialization a little more robust.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404012
parent 58ee5c66
......@@ -165,11 +165,12 @@ namespace dlib
long num = (long)std::floor(temp);
long num_total = (long)std::ceil(temp);
bool has_slack = false;
const scalar_type B_sign = (B > 0)? 1 : -1;
long count = 0;
for (long i = 0; i < alpha.nr(); ++i)
{
if (y(i) == 1)
if (y(i) == B_sign)
{
if (count < num)
{
......@@ -178,8 +179,7 @@ namespace dlib
}
else
{
has_slack = true;
if (num_total > num)
if (count < num_total)
{
++count;
alpha(i) = C*(temp - std::floor(temp));
......@@ -189,7 +189,7 @@ namespace dlib
}
}
if (count != num_total || has_slack == false)
if (count != num_total)
{
std::ostringstream sout;
sout << "Invalid QP3 constraint parameters of B: " << B << ", Cp: " << Cp << ", Cn: "<< Cn;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment