@@ -703,7 +703,7 @@ void benchmark_polytope_linear_program_optimization(
703
703
bool rounding=false,
704
704
bool centered=true,
705
705
unsigned int max_draws=80000,
706
- unsigned int num_burns=20000 ) {
706
+ unsigned int num_burns=10000 ) {
707
707
typedef Cartesian<NT> Kernel;
708
708
typedef std::vector<Point> pts;
709
709
typedef boost::mt19937 RNGType;
@@ -756,6 +756,8 @@ void benchmark_polytope_linear_program_optimization(
756
756
GaussianRDHRWalk::Walk<Polytope, RandomNumberGenerator> gaussian_walk (P, x0, lp_params.L , rng);
757
757
int n_warmstart_samples = 100 ;
758
758
759
+ std::cout << " Warm start" << std::endl;
760
+
759
761
for (int i = 0 ; i < n_warmstart_samples; i++) {
760
762
gaussian_walk.apply (P, x0, lp_params.L , walk_length, rng);
761
763
}
@@ -788,14 +790,15 @@ void benchmark_polytope_linear_program_optimization(
788
790
hmc.apply (rng, walk_length);
789
791
}
790
792
793
+ hmc.solver ->eta = hmc.solver ->eta *NT (10 );
794
+ hmc.disable_adaptive ();
795
+
791
796
std::cout << std::endl;
792
- std::cout << " Optimizing " << std::endl;
793
- unsigned int num_phases = 0 ;
797
+ std::cout << " Sampling " << std::endl;
798
+ unsigned int num_phases = 1 ;
794
799
795
800
auto start = std::chrono::high_resolution_clock::now ();
796
- for (unsigned int j = 0 ; j < max_phases; j++) {
797
- num_phases++;
798
- std::cout << " Temperature " << opt_params.T << std::endl;
801
+ for (unsigned int j = 0 ; j < 1 ; j++) {
799
802
for (unsigned int i = 0 ; i < max_actual_draws; i++) {
800
803
hmc.apply (rng, walk_length);
801
804
if (f_lp (minimum) >= f_lp (hmc.x )) {
@@ -813,12 +816,12 @@ void benchmark_polytope_linear_program_optimization(
813
816
814
817
NT ETA = (NT) std::chrono::duration_cast<std::chrono::microseconds>(stop - start).count ();
815
818
816
- std::cerr << " Min LP Value: " << f_lp (minimum) << std::endl;
819
+ std::cerr << " Min biomass Value: " << f_lp (minimum) << std::endl;
817
820
std::cerr << " Argmin: " << minimum.getCoefficients ().transpose () << std::endl;
818
- std::cerr << " Average ETA: " << ETA / (NT) num_phases << std::endl;
819
- std::cerr << " Average Time per Independent sample: " << ETA / total_min_ess << std::endl;
820
- std::cerr << " Average Max PSRF: " << total_max_psrf / (NT) num_phases << std::endl;
821
- std::cerr << " Average Min ESS: " << total_min_ess / (NT) num_phases << std::endl;
821
+ std::cerr << " ETA: " << ETA / (NT) num_phases << std::endl;
822
+ std::cerr << " Time per Independent sample: " << total_min_ess / ETA << std::endl;
823
+ std::cerr << " Max PSRF: " << total_max_psrf / (NT) num_phases << std::endl;
824
+ std::cerr << " Min ESS: " << total_min_ess / (NT) num_phases << std::endl;
822
825
std::cerr << " Average number of reflections: " <<
823
826
(1.0 * hmc.solver ->num_reflections ) / hmc.solver ->num_steps << std::endl;
824
827
std::cerr << " Step size (final): " << hmc.solver ->eta << std::endl;
@@ -893,10 +896,10 @@ void call_test_benchmark_polytopes_grid_search() {
893
896
std::make_tuple (generate_cube<Hpolytope>(100 , false ), " 100_cube" , false ),
894
897
std::make_tuple (generate_prod_simplex<Hpolytope>(50 , false ), " 50_prod_simplex" , false ),
895
898
std::make_tuple (generate_birkhoff<Hpolytope>(10 ), " 10_birkhoff" , false ),
896
- std::make_tuple (read_polytope<Hpolytope, NT>(" ./ metabolic_full_dim/polytope_iAB_RBC_283.ine" ), " iAB_RBC_283" , true ),
897
- std::make_tuple (read_polytope<Hpolytope, NT>(" ./ metabolic_full_dim/polytope_iAT_PLT_636.ine" ), " iAT_PLT_636" , true ),
898
- std::make_tuple (read_polytope<Hpolytope, NT>(" ./ metabolic_full_dim/polytope_e_coli.ine" ), " e_coli" , true ),
899
- std::make_tuple (read_polytope<Hpolytope, NT>(" ./ metabolic_full_dim/polytope_recon2.ine" ), " recon2" , true )
899
+ std::make_tuple (read_polytope<Hpolytope, NT>(" metabolic_full_dim/polytope_iAB_RBC_283.ine" ), " iAB_RBC_283" , true ),
900
+ std::make_tuple (read_polytope<Hpolytope, NT>(" metabolic_full_dim/polytope_iAT_PLT_636.ine" ), " iAT_PLT_636" , true ),
901
+ std::make_tuple (read_polytope<Hpolytope, NT>(" metabolic_full_dim/polytope_e_coli.ine" ), " e_coli" , true ),
902
+ std::make_tuple (read_polytope<Hpolytope, NT>(" metabolic_full_dim/polytope_recon2.ine" ), " recon2" , true )
900
903
};
901
904
902
905
Hpolytope P;
@@ -998,30 +1001,74 @@ void call_test_benchmark_spectrahedra_grid_search() {
998
1001
999
1002
}
1000
1003
1004
+ template <typename Point, typename NT>
1005
+ Point load_biomass_function (std::string name)
1006
+ {
1007
+ std::vector<double > v1;
1008
+ std::string line;
1009
+ NT element;
1010
+
1011
+ std::ifstream myFile (name);
1012
+ while (std::getline (myFile, line))
1013
+ {
1014
+ std::istringstream lineStream (line);
1015
+
1016
+ while (lineStream >> element) {
1017
+ v1.push_back (element);
1018
+ }
1019
+ }
1020
+ Point biomass_function = Point (v1.size (), v1);
1021
+ NT length = biomass_function.length ();
1022
+ biomass_function *= (NT (1 ) / length);
1023
+ return biomass_function;
1024
+ }
1025
+
1026
+ inline bool exists_check (const std::string& name) {
1027
+ std::ifstream f (name.c_str ());
1028
+ return f.good ();
1029
+ }
1030
+
1001
1031
template <typename NT>
1002
- void call_test_optimization () {
1032
+ void call_test_exp_sampling () {
1003
1033
typedef Cartesian<NT> Kernel;
1004
1034
typedef typename Kernel::Point Point;
1005
1035
typedef HPolytope<Point> Hpolytope;
1036
+ std::string name;
1037
+ std::vector<std::tuple<Hpolytope, Point, std::string, bool >> polytopes;
1038
+
1039
+
1040
+ if (exists_check (" metabolic_full_dim/e_coli_biomass_function.txt" ) && exists_check (" metabolic_full_dim/polytope_e_coli.ine" )){
1041
+ Point biomass_function_e_coli = load_biomass_function<Point, NT>(" metabolic_full_dim/e_coli_biomass_function.txt" );
1042
+ polytopes.push_back (std::make_tuple (read_polytope<Hpolytope, NT>(" metabolic_full_dim/polytope_e_coli.ine" ), biomass_function_e_coli, " e_coli" , true ));
1043
+ }
1006
1044
1007
- std::vector<std::tuple<Hpolytope, std::string, bool >> polytopes{
1008
- std::make_tuple (generate_cube<Hpolytope>(100 , false ), " 100_cube" , false ),
1009
- std::make_tuple (read_polytope<Hpolytope, NT>(" ./metabolic_full_dim/polytope_e_coli.ine" ), " e_coli" , true ),
1010
- };
1045
+ if (exists_check (" metabolic_full_dim/iAT_PTL_636_biomass_function.txt" ) && exists_check (" metabolic_full_dim/polytope_iAT_PTL_636.ine" )){
1046
+ Point biomass_function_iAT = load_biomass_function<Point, NT>(" metabolic_full_dim/iAT_PTL_636_biomass_function.txt" );
1047
+ polytopes.push_back (std::make_tuple (read_polytope<Hpolytope, NT>(" metabolic_full_dim/polytope_iAT_PTL_636.ine" ), biomass_function_iAT, " iAT_PTL_636" , true ));
1048
+ }
1049
+
1050
+ if (exists_check (" metabolic_full_dim/recon1_function.txt" ) && exists_check (" metabolic_full_dim/polytope_recon1.ine" )){
1051
+ Point biomass_function_recon1 = load_biomass_function<Point, NT>(" metabolic_full_dim/recon1_biomass_function.txt" );
1052
+ polytopes.push_back (std::make_tuple (read_polytope<Hpolytope, NT>(" metabolic_full_dim/polytope_recon1.ine" ), biomass_function_recon1, " recon1" , true ));
1053
+ }
1011
1054
1012
1055
Hpolytope P;
1013
- std::string name;
1014
1056
std::ofstream outfile;
1057
+ typedef BoostRandomNumberGenerator<boost::mt19937, NT> RNGType;
1015
1058
1016
- for (std::tuple<Hpolytope, std::string, bool > polytope_tuple : polytopes) {
1017
- P = std::get<0 >(polytope_tuple);
1018
- name = std::get<1 >(polytope_tuple);
1019
- std::cerr << name << std::endl;
1020
- P.normalize ();
1021
- Point coeffs = Point::all_ones (P.dimension ());
1022
- for (unsigned int walk_length = 500 ; walk_length <= P.dimension (); walk_length += P.dimension () / 10 ) {
1023
- benchmark_polytope_linear_program_optimization<NT, Hpolytope>(coeffs, P, 0 , NT (-1 ), walk_length, false );
1024
- }
1059
+ for (std::tuple<Hpolytope, Point, std::string, bool > polytope_tuple : polytopes) {
1060
+ P = std::get<0 >(polytope_tuple);
1061
+ name = std::get<2 >(polytope_tuple);
1062
+
1063
+ std::cerr << " Model: " + name << std::endl;
1064
+ std::cout<< " Dimension of " + name + " : " <<P.dimension ()<<std::endl;
1065
+
1066
+ P.normalize ();
1067
+ RNGType rng (P.dimension ());
1068
+ Point coeffs = std::get<1 >(polytope_tuple);
1069
+ for (unsigned int walk_length = P.dimension (); walk_length <= 2 *P.dimension (); walk_length += P.dimension ()) {
1070
+ benchmark_polytope_linear_program_optimization<NT, Hpolytope>(coeffs, P, 0 , NT (-1 ), walk_length, false );
1071
+ }
1025
1072
}
1026
1073
1027
1074
}
@@ -1145,8 +1192,8 @@ TEST_CASE("uld") {
1145
1192
call_test_uld<double >();
1146
1193
}
1147
1194
1148
- TEST_CASE (" optimization " ) {
1149
- call_test_optimization <double >();
1195
+ TEST_CASE (" exponential_biomass_sampling " ) {
1196
+ call_test_exp_sampling <double >();
1150
1197
}
1151
1198
1152
1199
TEST_CASE (" benchmark_hmc" ) {
0 commit comments