Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions components/hooks/ProblemProvider/Solver.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ export function useSolver(url, problemName, problemType, problemNameMap, problem
}

export function useSolverInfo(url, solver) {
// NOTE - Caleb - the following is a temporary solution to allow sat3 to be solved using the clique solver
// remove first if once this functionality is added for all problems, the false expression was the original
// functionality
return useGenericInfo(
url,
solver === "CliqueBruteForce - via SipserReduceToCliqueStandard" ? "CliqueBruteForce" : solver
);
return useGenericInfo(url, solver);
}

function useSolvedInstance(problemInstance, chosenSolver) {
Expand Down
4 changes: 2 additions & 2 deletions components/pageblocks/SolveRowReact.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "bootstrap/dist/css/bootstrap.min.css";
import { Button } from "@mui/material";
import { Download as DownloadIcon } from '@mui/icons-material';

import { requestSolvedInstanceTemporarySat3CliqueSolver } from "../redux";
import { requestSolvedInstance } from "../redux";
import PopoverTooltipClick from "../widgets/PopoverTooltipClick";
import { useSolverInfo } from "../hooks/ProblemProvider";
import ProblemSection from "../widgets/ProblemSection";
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function SolveRowReact({
async function handleSolve() {
setSolvedInstance(
chosenSolver && problemInstance
? (await requestSolvedInstanceTemporarySat3CliqueSolver(url, chosenSolver, problemInstance)) ?? ""
? (await requestSolvedInstance(url, chosenSolver, problemInstance)) ?? ""
: ""
);
}
Expand Down
55 changes: 0 additions & 55 deletions components/redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,61 +385,6 @@ export async function requestSolvedInstance(url, solver, instance) {
);
}

/**
* Temporary solution to allow solving 3 SAT with a Clique solver.
* All calls to this function should eventually be replace with `requestSolvedInstance`.
* A verbose name was purposefully chosen as a reminder to fix this.
* @returns the solved `instance` from the specified `solver`.
* @returns `undefined` on failure and logs the error.
*/
export async function requestSolvedInstanceTemporarySat3CliqueSolver(url, solver, instance) {
// NOTE - Caleb - the following is a temporary solution to allow sat3 to be solved using the clique solver
// remove first if once this functionality is added for all problems, the else code block was the original
// functionality
if (solver == "CliqueBruteForce - via SipserReduceToCliqueStandard") {
const reduction = await requestReducedInstance(url, "SipserReduceToCliqueStandard", instance);
if (!reduction) {
return undefined;
}

const solution = await requestSolvedInstance(url, "CliqueBruteForce", reduction.reductionTo.instance);
if (!solution) {
return undefined;
}

const mappedSolution = await fetchPostJson(
`${url}ProblemProvider/mapSolution?reduction=SipserReduceToSAT3&solution=${encodeURIComponent(solution)}`,
reduction.reductionTo.instance,
() => "TRANSITIVE SOLVED REQUEST FAILED"
);

return mappedSolution;
} else {
return await requestSolvedInstance(url, solver, instance);
}
}

/**
* @returns the solved graph visualization of the problem instance.
* @returns `undefined` on failure and logs the error.
*/
export async function requestSolvedVisualization(url, problem, instance, solution) {
// TODO: convert to POST request for problem instance
var preparedSolution = solution.replaceAll("&", "%26");
var preparedInstance = instance.replaceAll("&", "%26");
if (problem == "SipserReduceToCliqueStandard") {
return await fetchJson(
`${url}${problem}/solvedVisualization?problemInstance=${preparedInstance}&solution=${preparedSolution}`,
() => `${problem} VISUALIZE REQUEST FAILED`
);
} else {
return await fetchJson(
`${url}${problem}Generic/solvedVisualization?problemInstance=${preparedInstance}&solution=${preparedSolution}`,
() => `${problem} VISUALIZE REQUEST FAILED`
);
}
}

/**
* @returns the `steps` from the specified `solver`.
* @returns `undefined` on failure and logs the error.
Expand Down
Loading