Skip to content
Snippets Groups Projects
Commit 18fef5cb authored by Daniel Khashabi's avatar Daniel Khashabi
Browse files

adding a method to get the coefficient of the variable in the objective function.

parent f4ca1eec
No related branches found
No related tags found
1 merge request!2adding a method to get the coefficient of the variable in the objective function.
Pipeline #
......@@ -148,6 +148,11 @@ public class BeamSearch implements ILPSolver {
return this.objectiveValue;
}
@Override
public double objectiveCoeff(int index) {
return scores.get(index)[0];
}
public void reset() {
this.constraints = new ArrayList<ILPConstraint>();
this.scores = new ArrayList<double[]>();
......
......@@ -470,6 +470,11 @@ public class GurobiHook implements ILPSolver {
return 0;
}
@Override
public double objectiveCoeff(int index) {
return 0;
}
/**
* Given an array of variable indexes, this method returns the corresponding Gurobi variable
......
......@@ -161,6 +161,11 @@ public interface ILPSolver {
public double objectiveValue();
/**
* The coefficient of the variable in the objective function.
*/
public double objectiveCoeff(int index);
/**
* This method clears the all constraints and variables out of the ILP solver's problem
* representation, bringing the <code>ILPSolver</code> instance back to the state it was in when
......
......@@ -137,6 +137,11 @@ public class JLISCuttingPlaneILPSolverGurobi implements ILPSolver {
return baseSolver.objectiveValue();
}
@Override
public double objectiveCoeff(int index) {
return 0;
}
public void reset() {
baseSolver.reset();
......
......@@ -21,9 +21,6 @@ public class OJalgoHook implements ILPSolver {
private ExpressionsBasedModel model = new ExpressionsBasedModel();
private String nameOfObjectiveExpression = "objective";
private Expression objectiveFunction = model.getObjectiveExpression();
// Internal flag for keeping optimization state
private boolean minimize = true;
......@@ -301,6 +298,11 @@ public class OJalgoHook implements ILPSolver {
return result.getValue();
}
@Override
public double objectiveCoeff(int index) {
return model.getVariable(index).getContributionWeight().doubleValue();
}
public void reset() {
if(log)
System.out.println("OJalgoHook: reset()");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment