Hi,

is there a way in Java to ask to a XPRMModel if it had found any integer solution?

I know I can ask the status with getProblemStatus(), but if is unfinished with no integer solutions is clearly different from unfinished with one feasible solution.

Thanks,

Tiziano

You can use the method 'solutionAvailable' to check whether there is some solution information available after a model run from Java:

XPRMModel mod;

if(mod.getProblemStatus()==mod.PB_OPTIMAL || (mod.getProblemStatus()==mod.PB_UNFINISHED && mod.solutionAvailable()))

System.out.println("Status: " + mod.getProblemStatus() + " Objective value: " + mod.getObjectiveValue());

If you wish to know the exact number of solutions, this piece of information needs to be retrieved within the Mosel model and then passed to the Java program. There are several ways of achieving this, one possibility is to simply save the value into an integer scalar in the Mosel model:

declarations

public numnodes: integer

end-declarations

...

numnodes:= getparam("XPRS_NODES")

and then retrieve it into the Java program:

int numnd;

numnd=((XPRMReference)mod.findIdentifier("numnodes")).asInteger();

You could also use "initializations to" from Mosel to write out the scalar if it has previously been associated with a Java object, as in this example from the Mosel User Guide (file ugioscalar.java): FICO Xpress Optimization Examples Repository: In-memory data exchange