31 #include <boost/random.hpp>
32 #if not defined(WIN32) && not defined(WIN64)
34 #define HAVE_GETTIMEOFDAY
37 #include <boost/algorithm/string.hpp>
50 template<
class Matrix,
class SymmGroup>
68 #define BEGIN_TIMING(name) \
69 now = boost::chrono::high_resolution_clock::now();
70 #define END_TIMING(name) \
71 then = boost::chrono::high_resolution_clock::now(); \
72 maquis::cout << "Time elapsed in " << name << ": " << boost::chrono::duration<double>(then-now).count() << std::endl;
80 double x =
log(y1/y0)/(N-1);
86 template<
class Matrix,
class SymmGroup,
class Storage>
93 boost::function<
bool ()> stop_callback_,
100 std::size_t L =
mps.length();
103 for(
int i = 0; i <
mps.length(); ++i)
104 Storage::evict(
mps[i]);
106 northo = parms_[
"n_ortho_states"];
107 maquis::cout <<
"Expecting " <<
northo <<
" states to orthogonalize to." << std::endl;
111 throw std::runtime_error(
"Parameter \"ortho_states\" is not set\n");
114 std::string files_ = parms_[
"ortho_states"].str();
115 std::vector<std::string> files;
116 boost::split(files, files_, boost::is_any_of(
", "));
117 for (
int n = 0; n <
northo; ++n) {
118 maquis::cout <<
"Loading ortho state " << n <<
" from " << files[n] << std::endl;
120 maquis::cout <<
"Right end: " <<
ortho_mps[n][
mps.length()-1].col_dim() << std::endl;
124 maquis::cout <<
"Done init_left_right" << std::endl;
138 Storage::pin(
left_[site+1]);
140 for (
int n = 0; n <
northo; ++n)
147 Storage::pin(
right_[site]);
149 for (
int n = 0; n <
northo; ++n)
156 std::size_t L =
mps.length();
158 left_.resize(mpo.length()+1);
159 right_.resize(mpo.length()+1);
163 for (
int n = 0; n <
northo; ++n) {
172 Storage::drop(
left_[0]);
174 Storage::pin(
left_[0]);
176 for (
int i = 0; i < site; ++i) {
177 Storage::drop(
left_[i+1]);
179 Storage::evict(
left_[i]);
181 Storage::evict(
left_[site]);
184 maquis::cout <<
"Boundaries are partially initialized...\n";
191 for (
int i = L-1; i >= site; --i) {
194 Storage::evict(
right_[i+1]);
196 Storage::evict(
right_[site]);
199 maquis::cout <<
"Boundaries are fully initialized...\n";
205 if (sweep >=
parms.template get<int>(
"ngrowsweeps"))
206 cutoff =
parms.template get<double>(
"truncation_final");
208 cutoff =
log_interpolate(
parms.template get<double>(
"truncation_initial"),
parms.template get<double>(
"truncation_final"),
parms.template get<int>(
"ngrowsweeps"), sweep);
216 std::vector<std::size_t> ssizes =
parms.template get<std::vector<std::size_t> >(
"sweep_bond_dimensions");
217 if (sweep >= ssizes.size())
218 Mmax = *ssizes.rbegin();
220 Mmax = ssizes[
sweep];
222 Mmax =
parms.template get<std::size_t>(
"max_bond_dimension");
235 std::vector<Boundary<typename storage::constrained<Matrix>::type, SymmGroup> >
left_,
right_;
std::size_t get_Mmax(int sweep) const
optimizer_base(MPS< Matrix, SymmGroup > &mps_, MPO< Matrix, SymmGroup > const &mpo_, BaseParameters &parms_, boost::function< bool()> stop_callback_, int site=0)
void load(alps::hdf5::archive &ar, std::string const &path, TrivialGroup::charge &value, std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t > offset=std::vector< std::size_t >())
MPOTensor< Matrix, SymmGroup > const & mpo
std::vector< std::vector< int > > construct_placements(const MPO< Matrix, SymmGroup > &mpo)
SiteProblem(Boundary< typename storage::constrained< Matrix >::type, SymmGroup > const &left_, Boundary< typename storage::constrained< Matrix >::type, SymmGroup > const &right_, MPOTensor< Matrix, SymmGroup > const &mpo_)
bool is_set(std::string const &key) const
std::vector< Boundary< typename storage::constrained< Matrix >::type, SymmGroup > > left_
static block_matrix< OtherMatrix, SymmGroup > overlap_right_step(MPSTensor< Matrix, SymmGroup > const &bra_tensor, MPSTensor< Matrix, SymmGroup > const &ket_tensor, block_matrix< OtherMatrix, SymmGroup > const &right, block_matrix< OtherMatrix, SymmGroup > *localop=NULL)
optimization class for single-site algorithm
call IETL Jacobi-Davidson solver
std::vector< std::vector< block_matrix< typename storage::constrained< Matrix >::type, SymmGroup > > > ortho_left_
void init_left_right(MPO< Matrix, SymmGroup > const &mpo, int site)
static Boundary< OtherMatrix, SymmGroup > overlap_mpo_right_step(MPSTensor< Matrix, SymmGroup > const &bra_tensor, MPSTensor< Matrix, SymmGroup > const &ket_tensor, Boundary< OtherMatrix, SymmGroup > const &right, MPOTensor< Matrix, SymmGroup > const &mpo)
Boundary< typename storage::constrained< Matrix >::type, SymmGroup > const & left
virtual void sweep(int sweep, OptimizeDirection d=Both)=0
results_collector iteration_results_
static block_matrix< OtherMatrix, SymmGroup > overlap_left_step(MPSTensor< Matrix, SymmGroup > const &bra_tensor, MPSTensor< Matrix, SymmGroup > const &ket_tensor, block_matrix< OtherMatrix, SymmGroup > const &left, block_matrix< OtherMatrix, SymmGroup > *localop=NULL)
std::vector< std::vector< block_matrix< typename storage::constrained< Matrix >::type, SymmGroup > > > ortho_right_
boost::function< bool()> stop_callback
MPO< Matrix, SymmGroup > const & mpo
MPS< Matrix, SymmGroup > & mps
double get_cutoff(int sweep) const
static Boundary< OtherMatrix, SymmGroup > overlap_mpo_left_step(MPSTensor< Matrix, SymmGroup > const &bra_tensor, MPSTensor< Matrix, SymmGroup > const &ket_tensor, Boundary< OtherMatrix, SymmGroup > const &left, MPOTensor< Matrix, SymmGroup > const &mpo)
Logger< storage::archive > log
Boundary< typename storage::constrained< Matrix >::type, SymmGroup > const & right
results_collector const & iteration_results() const
std::vector< Boundary< typename storage::constrained< Matrix >::type, SymmGroup > > right_
optimization class for two-site algorithm
void boundary_right_step(MPO< Matrix, SymmGroup > const &mpo, int site)
std::vector< MPS< Matrix, SymmGroup > > ortho_mps
double log_interpolate(double y0, double y1, int N, int i)
void boundary_left_step(MPO< Matrix, SymmGroup > const &mpo, int site)
virtual ~optimizer_base()