Skip to content

Commit

Permalink
misc: update for latest boost (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 authored Jun 12, 2023
1 parent bbcdb42 commit acba887
Show file tree
Hide file tree
Showing 19 changed files with 164 additions and 144 deletions.
3 changes: 2 additions & 1 deletion Algorithms/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
* OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#define BOOST_PHOENIX_STL_TUPLE_H_
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include <time.h>
#include <stdlib.h>
Expand Down
4 changes: 3 additions & 1 deletion Algorithms/maxp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
#include <list>
#include <iterator>
#include <cstdlib>

#define BOOST_PHOENIX_STL_TUPLE_H_
#include <boost/unordered_map.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "../ShapeOperations/GalWeight.h"
#include "../logger.h"
Expand Down
133 changes: 66 additions & 67 deletions Algorithms/redcap.cpp

Large diffs are not rendered by default.

112 changes: 53 additions & 59 deletions Algorithms/redcap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@
#include <boost/heap/priority_queue.hpp>
#include <boost/graph/adjacency_list.hpp>




using namespace std;
using namespace boost;

namespace SpanningTreeClustering {

class Node;
Expand Down Expand Up @@ -73,8 +67,8 @@ namespace SpanningTreeClustering {
}
~SSDUtils() {}

double ComputeSSD(vector<int>& visited_ids, int start, int end);
void MeasureSplit(double ssd, vector<int>& visited_ids, int split_position, Measure& result);
double ComputeSSD(std::vector<int>& visited_ids, int start, int end);
void MeasureSplit(double ssd, std::vector<int>& visited_ids, int split_position, Measure& result);

};

Expand Down Expand Up @@ -165,51 +159,51 @@ namespace SpanningTreeClustering {
struct SplitSolution
{
int split_pos;
vector<int> split_ids;
std::vector<int> split_ids;
double ssd;
double ssd_reduce;
};

class Tree
{
public:
Tree(vector<int> ordered_ids,
vector<Edge*> _edges,
Tree(std::vector<int> ordered_ids,
std::vector<Edge*> _edges,
AbstractClusterFactory* cluster);

~Tree();

void Partition(int start, int end, vector<int>& ids,
vector<pair<int, int> >& od_array,
boost::unordered_map<int, vector<int> >& nbr_dict);
void Partition(int start, int end, std::vector<int>& ids,
std::vector<std::pair<int, int> >& od_array,
boost::unordered_map<int, std::vector<int> >& nbr_dict);
void Split(int orig, int dest,
boost::unordered_map<int, vector<int> >& nbr_dict,
vector<int>& cand_ids);
bool checkControl(vector<int>& cand_ids, vector<int>& ids, int flag);
pair<Tree*, Tree*> GetSubTrees();
boost::unordered_map<int, std::vector<int> >& nbr_dict,
std::vector<int>& cand_ids);
bool checkControl(std::vector<int>& cand_ids, std::vector<int>& ids, int flag);
std::pair<Tree*, Tree*> GetSubTrees();

double ssd_reduce;
double ssd;

vector<pair<int, int> > od_array;
std::vector<std::pair<int, int> > od_array;
AbstractClusterFactory* cluster;
pair<Tree*, Tree*> subtrees;
std::pair<Tree*, Tree*> subtrees;
int max_id;
int split_pos;
vector<int> split_ids;
vector<Edge*> edges;
vector<int> ordered_ids;
std::vector<int> split_ids;
std::vector<Edge*> edges;
std::vector<int> ordered_ids;
SSDUtils* ssd_utils;

double* controls;
double control_thres;

// threads
boost::mutex mutex;
void run_threads(vector<int>& ids,
vector<pair<int, int> >& od_array,
boost::unordered_map<int, vector<int> >& nbr_dict);
vector<SplitSolution> split_cands;
void run_threads(std::vector<int>& ids,
std::vector<std::pair<int, int> >& od_array,
boost::unordered_map<int, std::vector<int> >& nbr_dict);
std::vector<SplitSolution> split_cands;
};

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -226,7 +220,7 @@ namespace SpanningTreeClustering {
}
};

typedef heap::priority_queue<Tree*, heap::compare<CompareTree> > PriorityQueue;
typedef boost::heap::priority_queue<Tree*, boost::heap::compare<CompareTree> > PriorityQueue;

class AbstractClusterFactory
{
Expand All @@ -236,57 +230,57 @@ namespace SpanningTreeClustering {
GalElement* w;
double** dist_matrix;
double** raw_data;
const vector<bool>& undefs; // undef = any one item is undef in all variables
const std::vector<bool>& undefs; // undef = any one item is undef in all variables
double* controls;
double control_thres;
SSDUtils* ssd_utils;

//Cluster* cluster;
DisjoinSet djset;

vector<Node*> nodes;
vector<Edge*> edges;
std::vector<Node*> nodes;
std::vector<Edge*> edges;

vector<int> ordered_ids;
vector<Edge*> ordered_edges;
std::vector<int> ordered_ids;
std::vector<Edge*> ordered_edges;

vector<boost::unordered_map<int, double> > dist_dict;
std::vector<boost::unordered_map<int, double> > dist_dict;

vector<vector<int> > cluster_ids;
std::vector<std::vector<int> > cluster_ids;

AbstractClusterFactory(int row, int col,
double** distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w);
virtual ~AbstractClusterFactory();

virtual void Clustering()=0;

virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id,
bool is_orig_nbr, bool is_dest_nbr,
vector<int>& clst_ids,
vector<int>& clst_startpos,
vector<int>& clst_nodenum) { return 0;}
std::vector<int>& clst_ids,
std::vector<int>& clst_startpos,
std::vector<int>& clst_nodenum) { return 0;}

Edge* GetShortestEdge(vector<Edge*>& edges, int start, int end){ return NULL;}
Edge* GetShortestEdge(std::vector<Edge*>& edges, int start, int end){ return NULL;}

void init();
void Partitioning(int k);
vector<vector<int> >& GetRegions();
std::vector<std::vector<int> >& GetRegions();
};

////////////////////////////////////////////////////////////////////////////////
//
// 1 Skater
//
////////////////////////////////////////////////////////////////////////////////
typedef adjacency_list <
vecS,
vecS,
undirectedS,
typedef boost::adjacency_list <
boost::vecS,
boost::vecS,
boost::undirectedS,
boost::no_property, //VertexProperties
property < edge_weight_t, double> //EdgeProperties
boost::property <boost::edge_weight_t, double> //EdgeProperties
> Graph;

class Skater : public AbstractClusterFactory
Expand All @@ -295,7 +289,7 @@ namespace SpanningTreeClustering {
Skater(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres);
Expand All @@ -314,7 +308,7 @@ namespace SpanningTreeClustering {
FirstOrderSLKRedCap(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres);
Expand All @@ -335,7 +329,7 @@ namespace SpanningTreeClustering {
FirstOrderALKRedCap(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres);
Expand All @@ -357,7 +351,7 @@ namespace SpanningTreeClustering {
FirstOrderCLKRedCap(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres);
Expand All @@ -379,7 +373,7 @@ namespace SpanningTreeClustering {
FullOrderALKRedCap(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres,
Expand All @@ -389,9 +383,9 @@ namespace SpanningTreeClustering {

virtual void Clustering();

virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, bool is_orig_nbr, bool is_dest_nbr, vector<int>& clst_ids, vector<int>& clst_startpos, vector<int>& clst_nodenum);
virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, bool is_orig_nbr, bool is_dest_nbr, std::vector<int>& clst_ids, std::vector<int>& clst_startpos, std::vector<int>& clst_nodenum);

Edge* GetShortestEdge(vector<Edge*>& edges, int start, int end);
Edge* GetShortestEdge(std::vector<Edge*>& edges, int start, int end);
};

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -405,13 +399,13 @@ namespace SpanningTreeClustering {
FullOrderSLKRedCap(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres);
virtual ~FullOrderSLKRedCap();

virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, bool is_orig_nbr, bool is_dest_nbr, vector<int>& clst_ids, vector<int>& clst_startpos, vector<int>& clst_nodenum);
virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, bool is_orig_nbr, bool is_dest_nbr, std::vector<int>& clst_ids, std::vector<int>& clst_startpos, std::vector<int>& clst_nodenum);

};

Expand All @@ -427,14 +421,14 @@ namespace SpanningTreeClustering {
FullOrderCLKRedCap(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres);

virtual ~FullOrderCLKRedCap();

virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, bool is_orig_nbr, bool is_dest_nbr, vector<int>& clst_ids, vector<int>& clst_startpos, vector<int>& clst_nodenum);
virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, bool is_orig_nbr, bool is_dest_nbr, std::vector<int>& clst_ids, std::vector<int>& clst_startpos, std::vector<int>& clst_nodenum);

};

Expand All @@ -449,7 +443,7 @@ namespace SpanningTreeClustering {
FullOrderWardRedCap(int rows, int cols,
double** _distances,
double** data,
const vector<bool>& undefs,
const std::vector<bool>& undefs,
GalElement * w,
double* controls,
double control_thres);
Expand All @@ -458,7 +452,7 @@ namespace SpanningTreeClustering {

virtual void Clustering();

virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, double min_dist, bool is_orig_nbr, bool is_dest_nbr, vector<int>& clst_ids, vector<int>& clst_startpos, vector<int>& clst_nodenum, vector<int>& ids);
virtual double UpdateClusterDist(int cur_id, int orig_id, int dest_id, double min_dist, bool is_orig_nbr, bool is_dest_nbr, std::vector<int>& clst_ids, std::vector<int>& clst_startpos, std::vector<int>& clst_nodenum, std::vector<int>& ids);
};
}

Expand Down
4 changes: 2 additions & 2 deletions Algorithms/spatial_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include "../GdaConst.h"
#include "../ShapeOperations/GeodaWeight.h"
#include "spatial_validation.h"

#define BOOST_PHOENIX_STL_TUPLE_H_
namespace bg = boost::geometry;

#ifndef __NO_THREAD__
#ifndef __USE_PTHREAD__
#include <boost/system/config.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#else
#include <pthread.h>

Expand Down
5 changes: 3 additions & 2 deletions Algorithms/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include <stdlib.h>

#ifndef __JSGEODA__
#define BOOST_PHOENIX_STL_TUPLE_H_
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread.hpp>
#include <boost/atomic/atomic.hpp>
Expand Down Expand Up @@ -239,4 +240,4 @@ int test() {
}

#endif
#endif
#endif
12 changes: 12 additions & 0 deletions BuildTools/macosx/code_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@ def ProcessDependency(dylib_path, cid):
dylib_path = '/opt/homebrew/opt/geos/lib/libgeos.3.11.1.dylib'
if dylib_path == '@rpath/libgeos.3.11.0.dylib':
dylib_path = '/opt/homebrew/opt/geos/lib/libgeos.3.11.0.dylib'
if dylib_path == '@rpath/libgeos.3.11.2.dylib':
dylib_path = '/opt/homebrew/opt/geos/lib/libgeos.3.11.2.dylib'
if dylib_path == '@loader_path/libicuuc.71.dylib':
dylib_path = '/opt/homebrew/opt/icu4c/lib/libicuuc.71.dylib'
if dylib_path == '@loader_path/libicuuc.72.dylib':
dylib_path = '/opt/homebrew/opt/icu4c/lib/libicuuc.72.dylib'
if dylib_path == '@loader_path/libicudata.71.dylib':
dylib_path = '/opt/homebrew/opt/icu4c/lib/libicudata.71.dylib'
if dylib_path == '@loader_path/libicudata.72.dylib':
dylib_path = '/opt/homebrew/opt/icu4c/lib/libicudata.72.dylib'
if dylib_path == '@loader_path/libbrotlicommon.1.dylib':
dylib_path = '/opt/homebrew/opt/brotli/lib/libbrotlicommon.1.dylib'
if dylib_path == '@rpath/libsharpyuv.0.dylib':
dylib_path = '/opt/homebrew/opt/webp/lib/libsharpyuv.0.dylib'
if dylib_path == '@loader_path/libkmlbase.1.dylib':
dylib_path = '/opt/homebrew/opt/libkml/lib/libkmlbase.1.dylib'
if dylib_path == '@loader_path/libkmldom.1.dylib':
dylib_path = '/opt/homebrew/opt/libkml/lib/libkmldom.1.dylib'

if dylib_path == '@rpath/libIlmThread-3_1.30.dylib':
dylib_path = '/usr/local/opt/openexr/lib/libIlmThread-3_1.30.dylib'
Expand Down
3 changes: 2 additions & 1 deletion DialogTools/AbstractClusterDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#include <algorithm>
#include <limits>

#define BOOST_PHOENIX_STL_TUPLE_H_
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include <wx/wx.h>
#include <wx/xrc/xmlres.h>
Expand Down
1 change: 1 addition & 0 deletions DialogTools/AbstractClusterDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef __GEODA_CENTER_ABSTRACTCLUSTER_DLG_H___
#define __GEODA_CENTER_ABSTRACTCLUSTER_DLG_H___

#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#include <vector>
#include <map>
#include <wx/wx.h>
Expand Down
Loading

0 comments on commit acba887

Please sign in to comment.