package hu.u_szeged.nbo.server.plugins;
import hu.u_szeged.nbo.server.NBOServer;
import hu.u_szeged.nbo.server.User;
import hu.u_szeged.nbo.server.jni.JMILPClass;
import java.util.HashMap;
public class MILPSolver extends NBOPlugin {
private static final String subDirectoryName = "milp";
public MILPSolver(User user, String problemName, HashMap<String, String> inputFiles) {
super(user, problemName, inputFiles, subDirectoryName);
}
public void run() {
this.pluginLogger.info("The server began to compute the "+
user.getUserName()+"'s "+ task+" with MILPSolver ...");
NBOServer.log("The server began to compute the "+
user.getUserName()+"'s "+ task+" with MILPSolver ...", 1);
String result="";
String log="";
JMILPClass milp = new JMILPClass();
milp.initCppSide();
milp.setLogLevel(4);
milp.setInputMPSFileName(task);
milp.solve();
log += milp.getMessages();
for (int i=0; i < milp.getNumberColumns(); i++) {
result += i + ". variable: " + milp.getSolution( i ) + "\n";
}
milp.cleanUpCppSide();
/* try {
user.getNewResults().put(this.problemName+".mps", result);
user.getLogs().put(this.problemName+".mps", log);
PrintWriter pw = new PrintWriter(new FileWriter(this.pathOfTask+"/"+problemName+".out"));
pw.print(result);
pw.close();
this.pluginLogger.info(log);
this.pluginLogger.info("The server finished computing "+
user.getUserName()+"'s "+ task+" with MILPSolver ...");
NBOServer.log("The server finished computing "+
user.getUserName()+"'s "+ task+" with MILPSolver ...", 1);
}
catch(Exception e) {
this.pluginLogger.warning(e.toString());
NBOServer.log(e.toString(), 2);
} finally {
this.fileHandler.close();
}*/
}
}