c++ - How can I resolve <could not resolve type> message on operator "=" for deque<int>? -
i have passed deque variable function reference , trying set equal local deque variable of same type.
in main define:
vector<vector<deque<int>>> memo_r (max_city, vector<deque<int>>((1<<(max_city))-1));
then in function:
double held_karp( ... , vector<vector<deque<int>>> &memo_r, ... ){ deque<int> temp_route; temp_route.push_front(0); memo_r[x][y] = temp_route; }
but values temp_route not placed in memo_r[x][y]. when debugging message <could not resolve type>
. why might be? steps can fix/debug problem?
thanks!
all related code:
double held_karp(int pos, long long unsigned city_bit, int max_city, const vector<vector<double>>&graph, vector<vector<double>> &memo, vector<vector<deque<int>>> &memo_r, deque<int> &deque_reference) { if (city_bit == (1<<(max_city))-1) { //printf("%d 1^\n",pos); return graph[pos+1][0+1]; } if (memo[pos][city_bit] != -1) { //printf("%d 2^\n",pos); return memo[pos][city_bit]; } //ensure "lowest_result" accepted double lowest_result = numeric_limits<double>::max(); deque<int> temp_route; (int = 0; < max_city; i++) { if (i != pos && (city_bit & (1 << i)) == 0){ deque<int> lower_deque_local; //printf("%d !\n",pos); double new_lower = graph[pos+1][i+1] + held_karp(i, city_bit | (1 << i), max_city, graph, memo, memo_r, lower_deque_local); if (lowest_result > new_lower) { lowest_result = new_lower; temp_route = lower_deque_local; temp_route.push_front(i); //consider replace deque_reference better lower_deque //add node came deque_reference = lower_deque_local; deque_reference.push_front(i); } //lowest_result = min(lowest_result, graph[pos+1][i+1] + held_karp(i, city_bit | (1 << i), max_city, graph, memo)); } } memo[pos][city_bit] = lowest_result; memo_r[pos][city_bit] = temp_route; //printf("%d 3^\n",pos); return lowest_result; } int main(int argc, char * argv[]) { vector<vector<double>> graph (1000, vector<double>(1000 , 0)); //set max_city - 0 not used int max_city = fillgraph(graph,argv[1]); vector<vector<double>> memo (max_city, vector<double>((1<<(max_city))-1, -1)); vector<vector<deque<int>>> memo_r (max_city, vector<deque<int>>((1<<(max_city))-1)); deque<int> route; clock_t tstart = clock(); double time = held_karp(0, 1, max_city, graph, memo, memo_r, route); //print out printf("optimal tour length: %f\n", time); printf("tsp tour:\n"); //printf("1\n"); int size = (int)route.size(); (int = 0; < size; i++) { printf("%d\n",(route.back()+1)); route.pop_back(); } //printf("1\n"); printf("total time elapsed: %fs\n", (double)(clock() - tstart)/clocks_per_sec); }
when walk though execution in xcode can see data not copied memo_r[x][y] temp_route. index data should shows, displayed in ide empty. when click 'more info' see <could not resolve type>
message.
Comments
Post a Comment