Posts

Showing posts with the label Java

Simplex implementation in Java with sample code

Simplex is one of the powerful algorithm to solve linear programming problems. With simplex, we can maximise or minimise objective function with the given list of constraint. public class Simplex { private double[][] tableaux; // tableaux private int numberOfConstraints; // number of constraints private int numberOfOriginalVariables; // number of original variables private boolean maximizeOrMinimize; private static final boolean MAXIMIZE = true; private static final boolean MINIMIZE = false; private int[] basis; // basis[i] = basic variable corresponding to row i public Simplex(double[][] tableaux, int numberOfConstraint, int numberOfOriginalVariable, boolean maximizeOrMinimize) { this.maximizeOrMinimize = maximizeOrMinimize; this.numberOfConstraints = numberOfConstraint; this.numberOfOriginalVariables = numberOfOriginalVariable; this.tableaux = tableaux; basis = new int[numberOfConstraints]; for (int i = 0; i < ...

Tutorial on Connecting Java application to IBM DB2 Express-C edition (Windows)

Software Prerequisites ·           IBM DB2 Express-C ·           Java SE JDK To begin, we will need to write a Java App. An example is provided below, this app simply shows how to list all the lastname from Employee  table in Java app import java.sql.*; public class testing{  public static void main(String args[])  {        try       {              Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");              Connection con=DriverManager. getConnection("jdbc:db2: sample");              Statement stmt = con.createStatement();              ResultSet resultSet=stmt.executeQuery(" SELECT Lastname from Employee");              System.out.println("Got Results!");              while...