0

I am trying to implement an integer solver using Ojalgo across time series data, with only first-order constraints and a linear first-order objective function. All my variables are integers. I am instantiating the model with:

ExpressionsBasedModel model = new ExpressionsBasedModel();
for(DataObject obj : myData){
  Variable var = model.createVariable(obj.identifierString).integer(true).lower(0).weight(obj.cost);
}
//Then expressions are sort of tree-like
for(DataObjectContainer cont : myContainers){
  Expression expr = model.addExpression(cont.id).lower(cont.lower).upper(cont.upper);
  expr.setLinearFactors(cont.dataObjectList, cont.dataObjectLoadList);
}

Then I was trying model.minimise(), but the result I got out of that just evenly distributed variable didn't actually solve it. I wasn't sure how to access the results either. I was pulling model variables from model.getVariables(), and then just read those with var.getIntValue(). I also tried getting the result values by index, like result.get(i).

What is the canonical way to access results, and is model.minimise() sufficient to solve the integer model?

My data is pretty simple, but there is a lot of it. There are two types of containers that do not overlap between the same types, but two different types of containers might share some variables in their expressions.

I was trying to get an integer value that minimized a linear objective function.

1 Answer 1

0

You can get the variable values either from the Optimisation.Result returned by the minimise() method or from the variable instances, but you have to check the state of the returned result result.getState() – that's how you know if the problem was solved correctly or not.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.