Package org.ddolib.examples.layered.mcp
Class NaiveMCPSolver
java.lang.Object
org.ddolib.examples.layered.mcp.NaiveMCPSolver
Naive MCP solver which enumerates all the solution to find the best one. Used for tests.
-
Constructor Summary
ConstructorsConstructorDescriptionNaiveMCPSolver(MCPProblem problem) Creates a new naive solver for the given MCP instance. -
Method Summary
Modifier and TypeMethodDescriptionintbest()Returns the best value found so far.int[]Returns the best solution found so far.static intgetOptimalSolution(int[][] matrix) Given an adjacency matrix, solves naively the instance of MCP.voidmaximize()Enumerates all possible partitions and keeps track of the best one.
-
Constructor Details
-
NaiveMCPSolver
Creates a new naive solver for the given MCP instance.- Parameters:
problem- the MCP instance to solve
-
-
Method Details
-
getOptimalSolution
public static int getOptimalSolution(int[][] matrix) Given an adjacency matrix, solves naively the instance of MCP.- Parameters:
matrix- the adjacency matrix defining the MCP- Returns:
- the optimal solution of the MCP
-
best
public int best()Returns the best value found so far.- Returns:
- the best value found so far
-
bestSolution
public int[] bestSolution()Returns the best solution found so far.- Returns:
- the best solution found so far
-
maximize
public void maximize()Enumerates all possible partitions and keeps track of the best one.
-