Unable to read MPS file
回答済みHello everybody,
I have a problem with reading a (.mps) file in Java API. This is Java code:
*===========================
import gurobi.*;
public class Lp2 {
public static void main(String[] args) {
try {
GRBEnv env = new GRBEnv();
GRBModel model = new GRBModel(env);
model.read("C:\\Users\\A.Omidi\\Desktop\\flow_shop.mps");
model.optimize();
int optimstatus = model.get(GRB.IntAttr.Status);
System.out.println(optimstatus);
// Dispose of model and environment
model.dispose();
env.dispose();
} catch (GRBException e) {
System.out.println("Error code: " + e.getErrorCode() + ". " + e.getMessage());
}
}
}
*===========================
While I run the code I have a error: "Error code: 10012. Can't import file 'C:\Users\A.Omidi\Desktop\flow_shop.mps' into a model".
In the other software, I don't have any problem. Could you tell me please, is there a specific way to read (LP/MPS) file in Java?
Regards
Omidi. A
-
Hi,
to create a Gurobi model from a file you need to pass the file name to the model
constructor, e.g.,
GRBModel model = new GRBModel(env, "C:\\Users\\A.Omidi\\Desktop\\flow_shop.mps");
. See also https://www.gurobi.com/documentation/8.1/examples/load_and_solve_a_model_fro.html.
The model.read() method can be used to read in a parameter file or attributes
files, see also http://www.gurobi.com/documentation/8.1/refman/java_grbmodel_read.html.
Best,
Michael0 -
Hi,
Thanks so much for useful replay.
Its work fine.
Regards
Omidi. A
0
サインインしてコメントを残してください。
コメント
2件のコメント