Skip to content

Commit

Permalink
Removed restrictions on glm upper/lower bounds to be non-negative/non…
Browse files Browse the repository at this point in the history
…-positive. The only restriction is lb <= ub.
  • Loading branch information
tomasnykodym committed Jan 28, 2015
1 parent ab04e26 commit 5980d62
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/hex/glm/GLM2.java
Original file line number Diff line number Diff line change
Expand Up @@ -499,27 +499,32 @@ private double computeIntercept(DataInfo dinfo, double ymu, Vec offset, Vec resp
if((v = beta_constraints.vec("lower_bounds")) != null) {
_lbs = map == null ? Utils.asDoubles(v) : mapVec(Utils.asDoubles(v), makeAry(names.length, Double.NEGATIVE_INFINITY), map);
System.out.println("lower bounds = " + Arrays.toString(_lbs));
for(int i = 0; i < _lbs.length; ++i)
if(_lbs[i] > 0) throw new IllegalArgumentException("lower bounds must be non-positive");
// for(int i = 0; i < _lbs.length; ++i)
// if(_lbs[i] > 0) throw new IllegalArgumentException("lower bounds must be non-positive");
if(_srcDinfo._normMul != null) {
for (int i = numoff; i < _srcDinfo.fullN(); ++i) {
if (Double.isInfinite(_lbs[i])) continue;
_lbs[i] /= _srcDinfo._normMul[i - numoff];
}
}

}
if((v = beta_constraints.vec("upper_bounds")) != null) {
_ubs = map == null ? Utils.asDoubles(v) : mapVec(Utils.asDoubles(v), makeAry(names.length, Double.POSITIVE_INFINITY), map);
System.out.println("upper bounds = " + Arrays.toString(_ubs));
for(int i = 0; i < _ubs.length; ++i)
if (_ubs[i] < 0) throw new IllegalArgumentException("lower bounds must be non-positive");
// for(int i = 0; i < _ubs.length; ++i)
// if (_ubs[i] < 0) throw new IllegalArgumentException("lower bounds must be non-positive");
if(_srcDinfo._normMul != null)
for(int i = numoff; i < _srcDinfo.fullN(); ++i) {
if(Double.isInfinite(_ubs[i]))continue;
_ubs[i] /= _srcDinfo._normMul[i - numoff];
}
}

if(_lbs != null && _ubs != null) {
for(int i = 0 ; i < _lbs.length; ++i)
if(_lbs[i] > _ubs[i])
throw new IllegalArgumentException("Invalid upper/lower bounds: lower bounds must be <= upper bounds for all variables.");
}
if((v = beta_constraints.vec("beta_given")) != null) {
_bgs = map == null ? Utils.asDoubles(v) : mapVec(Utils.asDoubles(v), makeAry(names.length, 0), map);
if(_srcDinfo._normMul != null) {
Expand Down

0 comments on commit 5980d62

Please sign in to comment.