Ceres Solver for logistic growth Curve Fit - ceres-solver
I attempt to test how well ceres solver autodiff in fitting a simple logistic growth curve against actual observed data , to my surprise the solver seemed unable to provide solution . Using other c++ solvers , result can be easily obtained with ease , k=9643.61,c=84.61 and b=3.8121. I am not sure is the code having issue or just the ceres solver autodiff are not that well built? Any advice pls?
below is the sample
#include "ceres/ceres.h"
#include "glog/logging.h"
#include <cmath>
#include <iostream>
#include <stdio.h>
using ceres::AutoDiffCostFunction;
using ceres::CauchyLoss;
using ceres::CostFunction;
using ceres::Problem;
using ceres::Solve;
using ceres::Solver;
struct ExponentialResidual
{
ExponentialResidual(double x, double y)
: x_(x), y_(y) {}
template <typename T>
bool operator()(const T *const k,
const T *const c,
const T *const b,
//const T* const g,
T *residual) const
{
residual[0] = y_ - (k[0] / (1.0 + (pow((x_ / c[0]), b[0]))));
return true;
}
private:
const double x_;
const double y_;
};
const int kNumObservations = 247;
double data[] = {
0,3,
1,4,
2,4,
3,4,
4,7,
5,8,
6,8,
7,8,
8,8,
9,8,
10,10,
11,12,
12,12,
13,12,
14,16,
15,16,
16,18,
17,18,
18,18,
19,19,
20,19,
21,22,
22,22,
23,22,
24,22,
25,22,
26,22,
27,22,
28,22,
29,22,
30,22,
31,22,
32,22,
33,23,
34,23,
35,25,
36,29,
37,32,
38,36,
39,50,
40,55,
41,83,
42,93,
43,99,
44,117,
45,129,
46,149,
47,158,
48,197,
49,238,
50,428,
51,553,
52,673,
53,790,
54,900,
55,1030,
56,1183,
57,1306,
58,1518,
59,1624,
60,1796,
61,2031,
62,2161,
63,2320,
64,2470,
65,2626,
66,2766,
67,2908,
68,3116,
69,3333,
70,3483,
71,3662,
72,3793,
73,3963,
74,4119,
75,4228,
76,4346,
77,4530,
78,4683,
79,4817,
80,4987,
81,5072,
82,5182,
83,5251,
84,5305,
85,5389,
86,5425,
87,5482,
88,5532,
89,5603,
90,5691,
91,5742,
92,5780,
93,5820,
94,5851,
95,5945,
96,6002,
97,6071,
98,6176,
99,6298,
100,6353,
101,6383,
102,6428,
103,6467,
104,6535,
105,6589,
106,6656,
107,6726,
108,6742,
109,6779,
110,6819,
111,6855,
112,6872,
113,6894,
114,6941,
115,6978,
116,7009,
117,7059,
118,7137,
119,7185,
120,7245,
121,7417,
122,7604,
123,7619,
124,7629,
125,7732,
126,7762,
127,7819,
128,7857,
129,7877,
130,7970,
131,8247,
132,8266,
133,8303,
134,8322,
135,8329,
136,8336,
137,8338,
138,8369,
139,8402,
140,8445,
141,8453,
142,8494,
143,8505,
144,8515,
145,8529,
146,8535,
147,8556,
148,8572,
149,8587,
150,8590,
151,8596,
152,8600,
153,8606,
154,8616,
155,8634,
156,8637,
157,8639,
158,8640,
159,8643,
160,8648,
161,8658,
162,8663,
163,8668,
164,8674,
165,8677,
166,8683,
167,8696,
168,8704,
169,8718,
170,8725,
171,8729,
172,8734,
173,8737,
174,8755,
175,8764,
176,8779,
177,8800,
178,8815,
179,8831,
180,8840,
181,8861,
182,8884,
183,8897,
184,8904,
185,8943,
186,8956,
187,8964,
188,8976,
189,8985,
190,8999,
191,9001,
192,9002,
193,9023,
194,9038,
195,9063,
196,9070,
197,9083,
198,9094,
199,9103,
200,9114,
201,9129,
202,9149,
203,9175,
204,9200,
205,9212,
206,9219,
207,9235,
208,9240,
209,9249,
210,9257,
211,9267,
212,9274,
213,9285,
214,9291,
215,9296,
216,9306,
217,9317,
218,9334,
219,9340,
220,9354,
221,9360,
222,9374,
223,9385,
224,9391,
225,9397,
226,9459,
227,9559,
228,9583,
229,9628,
230,9810,
231,9868,
232,9915,
233,9946,
234,9969,
235,10031,
236,10052,
237,10147,
238,10167,
239,10219,
240,10276,
241,10358,
242,10505,
243,10576,
244,10687,
245,10769,
246,10919,
};
int main(int argc, char const *argv[])
{
google::InitGoogleLogging(argv[0]);
double k = 20000.0;
//double c=0.5;
double c = kNumObservations / 2.0;
double b = 0.5;
double g = 1.0;
Problem problem;
for (int i = 0; i < kNumObservations; i++)
{
problem.AddResidualBlock(
new AutoDiffCostFunction<ExponentialResidual, 1, 1, 1, 1>(
new ExponentialResidual(data[2 * i]*1.00, data[2 * i + 1]*1.00)),
new CauchyLoss(0.5), &k, &c, &b);
}
Solver::Options options;
options.max_num_iterations = 1000;
options.linear_solver_type = ceres::DENSE_QR;
//options.trust_region_strategy_type=ceres::DOGLEG;
//options.gradient_tolerance=1e-8;
//options.parameter_tolerance=1e-10;
//options.function_tolerance=1e-8;
options.minimizer_progress_to_stdout = true;
Solver::Summary summary;
Solve(options, &problem, &summary);
//std::cout<<summary.BriefReport()<<std::endl;
std::cout << summary.FullReport() << std::endl;
std::cout << "Final k: " << k << " c: " << c << " b: " << b << " g: " << g << "\n";
/* code */
return 0;
}
look like if I ignore the first observed data 0,3 , ceres solver is able to obtain result !
Related
apply 'with<>' to a skipper parser to get context
My first version of this question was rich with misunderstandings. My answer below suits my needs. But I kept at it to understand what could be done with with<>. What I get is that it intended to inject context into a parser. Then the parser is called from with_directive::parse (in x3's with.hpp) In the following code, that is just what happens. #include <boost/spirit/home/x3.hpp> using namespace boost::spirit::x3; struct eol_parser_cnt : parser<eol_parser_cnt> { struct context { int line = 0; std::string::iterator iter_pos; }; template <typename Iterator, typename Context, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context const& context, unused_type, Attribute& attr) const { //std::cout << context.line; auto& ctx = context; return boost::spirit::x3::parse(first, last, lit(' ') | (lit("//") >> *(char_ - eol) >> eol)); } }; const auto& our_skipper = eol_parser_cnt{}; eol_parser_cnt::context lines; auto with_skipper = with<eol_parser_cnt::context>(lines)[our_skipper]; int main() { std::string str("12 word"); auto first = str.begin(); phrase_parse(first, str.end(), int_ >> *char_("a-z"), with_skipper); } Putting a break point in eol_parser_cnt::parse and I see it working. The debugger consistently shows the context is there and that it is the structure of eol_parser_cnt::context. I can change the value of line in the debugger and the next hit shows that value, it is a real object. But, try to uncomment the line std::cout << context.line; and the compiler complains that is it an unused_type. So, I just don't get it. test.cpp(15,30): error C2039: 'line': is not a member of 'boost::spirit::x3::context<ID,T,Context>' with [ ID=eol_parser_cnt::context, T=eol_parser_cnt::context, Context=boost::spirit::x3::unused_type ] F:\cpp\boost_1_76_0\boost\spirit\home\x3\support\context.hpp(18): message : see declaration of 'boost::spirit::x3::context<ID,T,Context>' with [ ID=eol_parser_cnt::context, T=eol_parser_cnt::context, Context=boost::spirit::x3::unused_type ] F:\cpp\boost_1_76_0\boost\spirit\home\x3\directive\with.hpp(62): message : see reference to function template instantiation 'bool eol_parser_cnt::parse<Iterator,boost::spirit::x3::context<ID,T,Context>,Attribute>(Iterator &,const Iterator &,const boost::spirit::x3::context<ID,T,Context> &,boost::spirit::x3::unused_type,Attribute &) const' being compiled with [ Iterator=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>, ID=eol_parser_cnt::context, T=eol_parser_cnt::context, Context=boost::spirit::x3::unused_type, Attribute=const boost::spirit::x3::unused_type ]
Well, it took a while but I was going to understand this. I re-read C++ Template Metaprogramming seriously this time. Then looking at the x3 code I finally understood that with<> is just another parser wrapper. It is interesting to debug an optimized build and see just how much code disappears. VS shows all the disappeared stuff on the stack as inlined and what was 9 layers of parser calls becomes 2 into the likes of with_error_handling::on_error. Everything from my call to parse_rhs_main (in rule.hpp, line 232), is gone. So because with<> is just another parser wrapper and if the skipper is wrapped, the context is only avaliable to the skipper. But no big deal as the skipper is in the context of the main parser. The difference is that in the skipper object a get<skipper_eol_cnt>(context) returns a reference to the skipper_eol_cnt::context{}. Whereas in the main parser we have to us get<skipper_tag>(context) and this returns the with<> parser object. val is a member of that parser, the reference to the skipper_eol_cnt::context{}. So get<skipper_tag>(context).val retrieves the context we are looking for. So here it is, using with<> applied to a skipper. #include<iostream> #include <iomanip> #include <vector> //#define BOOST_SPIRIT_X3_DEBUG #include <boost/spirit/home/x3.hpp> #include <boost/fusion/adapted.hpp> using namespace boost::spirit::x3; struct skipper_eol_cnt : parser<skipper_eol_cnt> { struct context { int line = 1; std::string::iterator iter_pos; }; template <typename Iterator, typename Context, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context const& context, unused_type, Attribute& attr) const { const char* start_cmt = "/*"; const char* end_cmt = "*/"; if (first == last) return false; bool matched = false; //here we are getting from the 'with<>' wrapper auto& ctx = get<skipper_eol_cnt>(context); //skip: space | '//comment' boost::spirit::x3::parse(first, last, lit(' ') | (lit("//") >> *(char_ - eol)));//eol counted below //skip: '/*comment*/' if (detail::string_parse(start_cmt, first, last, unused, case_compare<Iterator>())) { for (; first != last; ++first) { if (detail::string_parse(end_cmt, first, last, unused, case_compare<Iterator>())) break; if (*first == '\n') ++ctx.line, ctx.iter_pos = first; } } Iterator iter = first; for (; iter != last && (*iter == '\r' || *iter == '\n'); ++iter) { matched = true; if (*iter == '\n') // LF ++ctx.line, ctx.iter_pos = iter; } //{static int pos = 0; if (pos < ctx.line) { pos = ctx.line; std::cout << pos << std::endl; }} if (matched) first = iter; return matched; } }; auto const& skip_eol_cnt = skipper_eol_cnt{}; struct with_error_handling { template<typename It, typename Ctx> error_handler_result on_error(It f, It l, expectation_failure<It> const& ef, Ctx const& ctx) const { It erit = f + std::distance(f, ef.where()); //here we are getting the wrapped skipper so need the 'with<>.val' const auto& sctx = get<skipper_tag>(ctx).val; It bit = erit; for (; *bit != '\n'/* && bit != f*/; --bit) ; It eit = erit; for (; *eit != '\n' && eit != l; ++eit) ; int str_pos = erit - bit - 1; std::ostringstream oss; oss << "Expecting " << ef.which() << "\n at line: " << sctx.line << "\n\t" << std::string(bit + 1, eit) << "\n\t" << std::setw(str_pos) << std::setfill('-') << "" << "^"; get<with_error_handling>(ctx).push_back(oss.str());; return error_handler_result::fail; } }; //attr sections struct section_type { std::string name; int line; std::string::iterator iter_pos; }; BOOST_FUSION_ADAPT_STRUCT(section_type, name) using sections_type = std::vector<section_type>; struct parser_find_sections : parser<parser_find_sections> { template<typename Iterator, typename Context, typename RContext, typename Attribute> bool parse(Iterator& first, Iterator const& last, Context const& context, RContext const& rcontext, Attribute& section) const { const auto& sssctx = get<skipper_eol_cnt>(context); //now here this doesn't work, unused_type, but const auto& sctx = get<skipper_tag>(context).val; auto to_line = [&sctx, first](auto& ctx) { _attr(ctx).line = sctx.line; //_attr(ctx).iter_pos = first; // this one will get at 'section color(x,x)' _attr(ctx).iter_pos = _where(ctx).begin(); // this one is '(x,x)' }; static_assert(BOOST_VERSION / 100 % 1000 >= 77); ////NOTE!!! if you have a boost version of less than 1.77, x3::seek will fail here ////quick fix, copy from: https://github.com/boostorg/spirit/blob/boost-1.78.0/include/boost/spirit/home/x3/directive/seek.hpp ////and paste to your boost file... return phrase_parse(first, last, *(seek["section"] >> (*alpha)[to_line]), get<skipper_tag>(context), section); } }; auto const parse_section = rule<with_error_handling, std::pair<int, int>>("the_sec_parser") = [] { return '(' > int_ > ',' > int_ > ')'; }(); template<typename T> std::ostream& operator << (std::ostream& os, std::pair<T, T>& t) { return os << t.first << ',' << t.second; } //errors std::vector<std::string> errors; auto with_errors = with<with_error_handling>(errors)[parse_section]; auto test_section = [](auto& content, auto& section) { //attr std::pair<int, int> attr; skipper_eol_cnt::context ctx{ section.line, section.iter_pos }; auto with_skip_cnt = with< skipper_eol_cnt>(ctx)[skip_eol_cnt]; auto first(section.iter_pos); return std::tuple(phrase_parse(first, content.end(), with_errors, with_skip_cnt, attr), attr); }; int main() { std::string str(R"(//line 1 section red(5, 6) section green( 7, 8) //line 3 section blue(9, 10) //no error /*comment bunch of lines of stuff.... */ section white(11, a 12) //error on line 7 section black( 13,14) )"); //get the list of sections auto with_skip_cnt = with<skipper_eol_cnt>(skipper_eol_cnt::context{})[skip_eol_cnt]; sections_type secs; auto first(str.begin()); phrase_parse(first, str.end(), parser_find_sections(), with_skip_cnt, secs); for (auto& item : secs) std::cout << item.name << "\t at line: " << item.line << std::endl; //section 'blue', at 2, has no error auto [r, attr] = test_section(str, secs.at(2)); if (r) std::cout << "\nthe " << secs.at(2).name << " hase vals: " << attr << "\n\n"; //section 'white', at 3, has an error test_section(str, secs.at(3)); if (errors.size()) std::cout << errors.front() << std::endl; return 0; }
How to produce same mfcc result as librosa using aubio?
I am trying to calculate Mfcc feature in C++. And I found Aubio (https://github.com/aubio/aubio) but I cannot produce same result as Librosa of Python (this is important). Librosa code: X, sample_rate = sf.read(file_name, dtype='float32') mfccs = librosa.feature.mfcc(y=X, sr=sample_rate, n_mfcc=40) Aubio code: #include "utils.h" #include "parse_args.h" #include <stdlib.h> aubio_pvoc_t *pv; // a phase vocoder cvec_t *fftgrain; // outputs a spectrum aubio_mfcc_t * mfcc; // which the mfcc will process fvec_t * mfcc_out; // to get the output coefficients uint_t n_filters = 128; uint_t n_coefs = 40; void process_block (fvec_t *ibuf, fvec_t *obuf) { fvec_zeros(obuf); //compute mag spectrum aubio_pvoc_do (pv, ibuf, fftgrain); //compute mfccs aubio_mfcc_do(mfcc, fftgrain, mfcc_out); } void process_print (void) { /* output times in selected format */ print_time (blocks * hop_size); outmsg ("\t"); /* output extracted mfcc */ fvec_print (mfcc_out); } int main(int argc, char **argv) { int ret = 0; // change some default params buffer_size = 2048; hop_size = 512; examples_common_init(argc,argv); verbmsg ("using source: %s at %dHz\n", source_uri, samplerate); verbmsg ("buffer_size: %d, ", buffer_size); verbmsg ("hop_size: %d\n", hop_size); pv = new_aubio_pvoc (buffer_size, hop_size); fftgrain = new_cvec (buffer_size); mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate); mfcc_out = new_fvec(n_coefs); if (pv == NULL || fftgrain == NULL || mfcc == NULL || mfcc_out == NULL) { ret = 1; goto beach; } examples_common_process(process_block, process_print); printf("\nlen=%u\n", mfcc_out->length); del_aubio_pvoc (pv); del_cvec (fftgrain); del_aubio_mfcc(mfcc); del_fvec(mfcc_out); beach: examples_common_del(); return ret; } Please help to obtain same result of Librosa or suggest any C++ library do this well. Thanks
This might be what you are looking for: C Speech Features The library is a complete port of python_speech_features to C and according to the documentation, you should be able to use it in a C++ projects. The results will not be the same of Librosa, here is why but you should be able to work with them.
boost last_write_time is back one hour
I have trying to solve a bug on the following code, where I get an hour difference from boost last_write_time. To explain it better: I create a file, and then I try to extract the time it was created with boost::filesystem::path. void PrintTime(boost::filesystem::path _file) { time_t sys_time{ last_write_time(_file) }; ptime p_time{ boost::posix_time::from_time_t(sys_time) }; boost::posix_time::time_duration time_dur{ p_time.time_of_day() }; long h{ time_dur.hours() }; //1a long m{ time_dur.minutes() }; long s{ time_dur.seconds() }; //...print h, m, s. } //1a: Here when for example the time I expect is 12:34:56, //I always get 11:34:56 Any idea why is that? Is there timezone somewhere in boost last_write_time? My os displays the right time when I check the file through the system.
You have to translate to the "presentation" time-zone, like "when [you] check the file through the system". The timestamp from the filesystem is UTC time. E.g. if you do std::cout << boost::posix_time::second_clock::local_time() << "\n"; std::cout << boost::posix_time::second_clock::universal_time() << "\n"; you'll probably get 2018-Feb-27 16:03:12 2018-Feb-27 15:03:12 Fix: #include <boost/date_time/c_local_time_adjustor.hpp> void PrintTime(boost::filesystem::path _file) { using boost::posix_time::ptime; using adj = boost::date_time::c_local_adjustor<ptime>; time_t const sys_time = last_write_time(_file); ptime const utc = boost::posix_time::from_time_t(sys_time); ptime const local = adj::utc_to_local(utc); DEMO See it Live On Coliru #include <boost/filesystem.hpp> #include <boost/date_time/posix_time/posix_time_io.hpp> #include <boost/date_time/posix_time/conversion.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/c_local_time_adjustor.hpp> void PrintTime(boost::filesystem::path _file) { using boost::posix_time::ptime; using adj = boost::date_time::c_local_adjustor<ptime>; time_t const sys_time = last_write_time(_file); ptime const utc = boost::posix_time::from_time_t(sys_time); ptime const local = adj::utc_to_local(utc); std::cout << "utc: " << utc << "\n"; std::cout << "local: " << local << "\n"; { long h{ local.time_of_day().hours() }; long m{ local.time_of_day().minutes() }; long s{ local.time_of_day().seconds() }; //...print h, m, s. std::cout << h << ":" << m << ":" << s << '\n'; } } int main() { PrintTime("main.cpp"); } Prints (on my system): utc: 2018-Feb-27 15:19:45 local: 2018-Feb-27 16:19:45 16:19:45
Idiomatic complete matching with post skipping
What is the most idiomatic way to do post-skipping? More specific I want to ensure there is no "non-skippable" (garbage) characters in my input after matching my top rule. auto const blankOrComment = ascii::space | x3::lexeme ['#' >> *(x3::char_ - x3::eol) >> -x3::eol ] ; auto const program = rule<AstProgram>("program") = *(as<AstDefinition> (definition > ";")) ; auto const programEntry = x3::skip(blankOrComment) [program]; One idea, I consider quite ugly was to do a separate parse call for the blankOrComment afterwards, if the main iterator position is not the end iterator. The current better idea I have is to change the root rule: auto const programEntry = x3::skip(blankOrComment) [program >> x3::omit[*blankOrComment]]; Is there a more idiomatic way?
The simplest hack is to tack on >> eps: Live On Coliru Note I'd strive to make the skipper more self-descriptive: auto const skipper = space | '#' >> *(char_ - eol) >> (eol|eoi) ; Likewise you can make that postskip hack more self-descriptive: auto const post_skip = eps; auto const program = "program" >> post_skip; Live On Coliru #include <iostream> #define BOOST_SPIRIT_X3_DEBUG #include <boost/spirit/home/x3.hpp> namespace Parser { namespace x3 = boost::spirit::x3; namespace rules { using namespace x3; auto const skipper = space | '#' >> *(char_ - eol) >> (eol|eoi) ; auto const post_skip = eps; auto const program = "program" >> post_skip; } auto const programEntry = x3::skip(rules::skipper) [rules::program]; } int main() { using It = std::string::const_iterator; for (std::string const input : { "", " program ", "#hello\n program # comment\n", }) { It f = input.begin(), l = input.end(); if(parse(f, l, Parser::programEntry)) { std::cout << "Parse success\n"; } else { std::cout << "Parse failed\n"; } std::cout << "Remaining: '" << std::string(f,l) << "'\n"; } } Prints Parse failed Remaining: '' Parse success Remaining: '' Parse success Remaining: ''
What Time Is This Returning
Deep in the sauce here. I haven't worked with time to much so I'm a little confused here. I know there is FILETIME and SYSTEMTIME. What I am trying to get at this point (because it might change) are file that are less than a 20 seconds old. This returning the files and their size and something in seconds, What I'd like to know is where it is filtering by time if it is, and how can I adjust it to suit my needs. Thank you. using namespace std; typedef vector<WIN32_FIND_DATA> tFoundFilesVector; std::wstring LastWriteTime; int getFileList(wstring filespec, tFoundFilesVector &foundFiles) { WIN32_FIND_DATA findData; HANDLE h; int validResult=true; int numFoundFiles = 0; h = FindFirstFile(filespec.c_str(), &findData); if (h == INVALID_HANDLE_VALUE) return 0; while (validResult) { numFoundFiles++; foundFiles.push_back(findData); validResult = FindNextFile(h, &findData); } return numFoundFiles; } void showFileAge(tFoundFilesVector &fileList) { unsigned _int64 fileTime, curTime, age; tFoundFilesVector::iterator iter; FILETIME ftNow; //__int64 nFileSize; //LARGE_INTEGER li; //li.LowPart = ftNow.dwLowDateTime; //li.HighPart = ftNow.dwHighDateTime; CoFileTimeNow(&ftNow); curTime = ((_int64) ftNow.dwHighDateTime << 32) + ftNow.dwLowDateTime; for (iter=fileList.begin(); iter<fileList.end(); iter++) { fileTime = ((_int64)iter->ftLastWriteTime.dwHighDateTime << 32) + iter->ftLastWriteTime.dwLowDateTime; age = curTime - fileTime; cout << "FILE: '" << iter->cFileName << "', AGE: " << (_int64)age/10000000UL << " seconds" << endl; } } int main() { string fileSpec = "*.*"; tFoundFilesVector foundFiles; tFoundFilesVector::iterator iter; int foundCount = 0; getFileList(L"c:\\Mapper\\*.txt", foundFiles); getFileList(L"c:\\Mapper\\*.jpg", foundFiles); foundCount = foundFiles.size(); if (foundCount) { cout << "Found "<<foundCount<<" matching files.\n"; showFileAge(foundFiles); } system("pause"); return 0; }
I don't know what you've done to try to debug this but your code doesn't work at all. The reason is you're passing getFileList() a wstring but then passing that to the ANSI version of FindFirstFile(). Unless you #define UNICODE or use the appropriate compiler option, all system calls will expect char *, not UNICODE. The easiest fix is to simply change the declaration of getFileList() to this: int getFileList(const char * filespec, tFoundFilesVector &foundFiles) Change the call to FindFirstFile() to this: h = FindFirstFile((LPCSTR)filespec, &findData); And then change the calls to it to this: getFileList("c:\\Mapper\\*.txt", foundFiles); getFileList("c:\\Mapper\\*.jpg", foundFiles); Your other option is to switch all char strings to wide chars, but either way you need to be consistent throughout. Once you do that the program works as expected. As for your final question, your program is not filtering by time at all.
Not quite an answer, but you might want to read about file system tunneling. It may prevent you from what you're trying to do in some situations.