Created
July 19, 2018 11:17
-
-
Save henrybear327/d613a7726d2c0742bff416f98edb9eac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
assumptions | |
1. have 1*1 cells | |
2. no rotation | |
3. no overlapping | |
*/ | |
int greedySolver(vector<Shape> shapes, Floor floorDimension) | |
{ | |
// generate starting state | |
// (x2, x3, ..., xn) | |
CellVector candidateState = generateStartingCellVector()); | |
CellVector bestCaseSoFar; | |
// iteraive algorithm | |
// repeat starting state -> floor plan -> refine result loop | |
while(true) { | |
// attempt to floor plan based on the NTUPlacer: using b* tree + simulated annealing | |
FloorPlan floorplan = floorPlanningEngine(candidateState, floorDimension); | |
// refine the answer | |
// greedy: attempt to pick the possible next step (dominating relation) | |
// if floor plan can be done, keep on going by selecting the best cost | |
// if not, backtrack | |
candidateState = refineCellVector(candidateState, floorPlan.exist()); | |
if(floorPlan.exist() == true) | |
bestCaseSoFar = bestof(candidateState, bestCaseSoFar); | |
// we have run out of next state | |
if(candidateState.hasNextState() == false) | |
break; | |
} | |
// return the cost | |
return cost(bestCaseSoFar); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment