package dml.test.integration.applications;

import org.junit.Test;

import java.util.HashMap;

import dml.runtime.matrix.io.MatrixValue.CellIndex;
import dml.test.integration.AutomatedTestBase;
import dml.test.integration.TestConfiguration;
import dml.test.utils.TestUtils;

public class L2SVMTest extends AutomatedTestBase {
	private final static String TEST_DIR = "applications/l2svm/";
	private final static String TEST_L2SVM = "L2SVMTest";

	@Override
	public void setUp() {
		setUpBase();
    	addTestConfiguration(TEST_L2SVM, new TestConfiguration(TEST_DIR, "L2SVMTest",
                new String[] { "w" }));
	}
	
	@Test
    public void testL2SVM(){
		int rows = 1000;
        int cols = 100;

        TestConfiguration config = getTestConfiguration(TEST_L2SVM);
        config.addVariable("rows", rows);
        config.addVariable("cols", cols);
        config.addVariable("eps", Math.pow(10, -8));
        config.addVariable("lambda", 1);
      
        loadTestConfiguration(config);

        double[][] X = getRandomMatrix(rows, cols, 0, 1, 0.01, -1);
        double[][] y = getRandomMatrix(rows, 1, -1, 1, 1, -1);
        for(int i=0; i<rows; i++)
        	y[i][0] = (y[i][0] > 0) ? 1 : -1;
        
        writeInputMatrix("X", X, true);
        writeInputMatrix("y", y, true);
        
        runTest();
        runRScript();
        
		HashMap<CellIndex, Double> wR = readRMatrixFromFS("w");
        HashMap<CellIndex, Double> wDML= readDMLMatrixFromHDFS("w");
        TestUtils.compareMatrices(wR, wDML, Math.pow(10, -14), "wR", "wDML");
	}
}

@@ -1475,24 +1475,42 @@
 w%22);%0A       
+ boolean success =
  TestUtils.c
@@ -1568,13 +1568,55 @@
 wDML%22);%0A
+        //System.out.println(success+%22%22);%0A
 %09%7D%0A%7D%0A

Change DML scripts - L2SVM.dml