import org.xilaew.jampl.CLI;
public class AmplCliTest {
public static void main(String[] args) {
CLI cli = AmplFactory.createCLI();
// Thread errorThread = new Thread() {
// byte[] buff = new byte[100];
//
// public void run() {
// while (true) {
// try {
// cli.getErrorStream().read(buff);
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// System.err.println(buff);
// }
// };
// };
// errorThread.start();
cli.sendCommand("option solver ilogcp;");
cli.sendCommand("model output/assignment.mod;");
cli.sendCommand("data output/assignment0.dat;");
cli.sendCommand("solve;");
cli.sendCommand("show;");
cli.sendCommand("display a, return, x;");
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
while (cli.getErrorStream().available() > 0) {
System.err.print((char) cli.getErrorStream().read());
}
String s;
while ((s = cli.readLine()) != null) {
System.out.println(s);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();