Is there any advantage of HalfspaceToRandomBayesianFactor wrt SeparateLinearToRandomBayesian? If not, we might need to change the converter for allowing H-factors without non-negative constraints. Or at least, set a flag for controlling which one is used.
Here you have a simple code where one works and the other does not.
double[][] coef = ArraysUtil.reshape2d(new double[]{1,0,0,1}, 2,2);
double[] vals0 = new double[]{0,1};
double[] vals1 = new double[]{1,0};
SeparateHalfspaceFactorFactory ff = SeparateHalfspaceFactorFactory
.factory()
.domain(Strides.as(0,2), Strides.as(1,2));
ff.constraint(coef[0], Relationship.EQ, vals0[0], 0);
ff.constraint(coef[1], Relationship.EQ, vals0[1], 0);
ff.constraint(coef[0], Relationship.EQ, vals1[0], 1);
ff.constraint(coef[1], Relationship.EQ, vals1[1], 1);
// Non-negativeness constraints
if(false) {
ff.constraint(new double[]{1, 0}, Relationship.GEQ, 0.0, 0);
ff.constraint(new double[]{0, 1}, Relationship.GEQ, 0.0, 0);
ff.constraint(new double[]{1, 0}, Relationship.GEQ, 0.0, 1);
ff.constraint(new double[]{0, 1}, Relationship.GEQ, 0.0, 1);
}
SeparateHalfspaceDefaultFactor f = (SeparateHalfspaceDefaultFactor) ff.get();
f.printLinearProblem();
// This works without non-neg constraints
BayesianFactor bf1 = new SeparateLinearToRandomBayesian().apply(f, 0);
System.out.println(bf1);
// This does not work (unfeasible solution)
BayesianFactor bf2 = new HalfspaceToRandomBayesianFactor().apply(f,0);
System.out.println(bf2);
When running approxLP, in the method
ch.idsia.crema.inference.approxlp1.Neighbourhood::randomuses the converter HalfspaceToRandomBayesianFactor, which would fail if the H-factor does not contain the non-negative constraints. However, this is not the case SeparateLinearToRandomBayesian, which was indeed the converter used in older crema versions.Is there any advantage of HalfspaceToRandomBayesianFactor wrt SeparateLinearToRandomBayesian? If not, we might need to change the converter for allowing H-factors without non-negative constraints. Or at least, set a flag for controlling which one is used.
Here you have a simple code where one works and the other does not.
@cbonesana, @davidhuber , what do you think?