Example usage for org.apache.commons.math.optimization.linear LinearObjectiveFunction getCoefficients

List of usage examples for org.apache.commons.math.optimization.linear LinearObjectiveFunction getCoefficients

Introduction

In this page you can find the example usage for org.apache.commons.math.optimization.linear LinearObjectiveFunction getCoefficients.

Prototype

public RealVector getCoefficients() 

Source Link

Document

Get the coefficients of the linear equation being optimized.

Usage

From source file:com.polytech4A.cuttingstock.core.method.LinearResolutionMetodTest.java

@Test
public void testUpdateFunction() throws NoSuchFieldException, IllegalAccessException {
    LinearResolutionMethod method = new LinearResolutionMethod(context);
    method.updateFunction(solution);//  www . j  av  a 2 s . c  om
    // To avoid set attributes in public, we get the field function.
    Field field = method.getClass().getDeclaredField("function");
    field.setAccessible(true);
    LinearObjectiveFunction f = (LinearObjectiveFunction) field.get(method);
    // Test of the function
    //  Coefficients value = sheet cost
    for (double d : f.getCoefficients().getData()) {
        assertEquals((double) context.getSheetCost(), d);
    }
    // Number of coefficients has to equal the number of patterns of the solution.
    assertEquals(solution.getPatterns().size(), f.getCoefficients().getDimension());
}