Skip to content

Commit 2f9aa1f

Browse files
committed
Merge remote-tracking branch 'origin/v10-minor'
2 parents f6db204 + f7bf6ea commit 2f9aa1f

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ Fixed bugs
7171
- avoid crash when initial IIS solve fails while reporting errors explicitly
7272
- fixed failure in nl writing on big endian machines
7373

74+
Miscellaneous
75+
-------------
76+
77+
- updated ampl/mp to version 4.0.4
7478

7579
@section RN1000 SCIP 10.0.0
7680
***************************

src/amplmp/include/mp/format.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,8 @@ struct FormatSpec : AlignSpec {
16451645
char type_;
16461646

16471647
FormatSpec(
1648-
unsigned width = 0, char type = 0, wchar_t fill = ' ')
1649-
: AlignSpec(width, fill), flags_(0), precision_(-1), type_(type) {}
1648+
unsigned width = 0, char type = 0, wchar_t fill = ' ', int prec = -1)
1649+
: AlignSpec(width, fill), flags_(0), precision_(prec), type_(type) {}
16501650

16511651
bool flag(unsigned f) const { return (flags_ & f) != 0; }
16521652
int precision() const { return precision_; }
@@ -2344,9 +2344,20 @@ class SystemError : public internal::RuntimeError {
23442344
template <typename Char>
23452345
class BasicWriter {
23462346
private:
2347-
// Output buffer.
2347+
/// Output buffer.
23482348
Buffer<Char> &buffer_;
23492349

2350+
FormatSpec fmtspec_double_
2351+
{
2352+
0, 0, ' ',
2353+
std::numeric_limits<double>::max_digits10
2354+
};
2355+
FormatSpec fmtspec_long_double_
2356+
{
2357+
0, 0, ' ',
2358+
std::numeric_limits<long double>::max_digits10
2359+
};
2360+
23502361
FMT_DISALLOW_COPY_AND_ASSIGN(BasicWriter);
23512362

23522363
typedef typename internal::CharTraits<Char>::CharPtr CharPtr;
@@ -2548,7 +2559,7 @@ class BasicWriter {
25482559
}
25492560

25502561
BasicWriter &operator<<(double value) {
2551-
write_double(value, FormatSpec());
2562+
write_double(value, fmtspec_double_);
25522563
return *this;
25532564
}
25542565

@@ -2559,7 +2570,7 @@ class BasicWriter {
25592570
\endrst
25602571
*/
25612572
BasicWriter &operator<<(long double value) {
2562-
write_double(value, FormatSpec());
2573+
write_double(value, fmtspec_long_double_);
25632574
return *this;
25642575
}
25652576

src/amplmp/include/mp/nl-reader.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,7 @@ class NLProblemBuilder {
21202120
AddVariables(h);
21212121
if (int n = h.num_common_exprs())
21222122
builder_.AddCommonExprs(n);
2123+
builder_.NotifyObjChoice(h.num_objs, multiobj(), objno());
21232124
int n_objs = resulting_nobj( h.num_objs );
21242125
if (n_objs != 0)
21252126
builder_.AddObjs( n_objs );
@@ -2533,13 +2534,19 @@ class NameProvider {
25332534
/// Returns the name of the item at specified index.
25342535
/// @param i2: if >=0,
25352536
/// from this index, generic name 2 is used
2536-
fmt::StringRef name(std::size_t index, std::size_t i2=-1);
2537+
/// @param any_empty: if non-0, set true if the read
2538+
/// name was empty (it is replaced by a standard name then).
2539+
fmt::StringRef name(
2540+
std::size_t index, std::size_t i2=-1, bool* was_empty=0);
25372541

25382542
/// Return vector of names, length n.
25392543
/// If number_read() < n, generic names are filled.
25402544
/// @param i2: if >=0,
25412545
/// from this index, generic name 2 is used
2542-
std::vector<std::string> get_names(size_t n, size_t i2=-1);
2546+
/// @param any_empty: if non-0, true iff had any empty names
2547+
/// in the input (they were replaced by standard names then).
2548+
std::vector<std::string> get_names(
2549+
size_t n, size_t i2=-1, bool* p_any_empty=0);
25432550

25442551
private:
25452552
std::vector<const char *> names_;

src/amplmp/src/nl-reader.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,22 @@ void mp::NameProvider::ReadNames(
354354
}
355355

356356
fmt::StringRef mp::NameProvider::name(
357-
std::size_t index, std::size_t i2) {
357+
std::size_t index, std::size_t i2, bool* was_empty) {
358358
if (index + 1 < names_.size()) {
359359
const char *name = names_[index];
360360
const auto* pos1past = names_[index + 1] - 1;
361361
assert( ('\n' == *pos1past) || ('\r' == *pos1past));
362362
if (pos1past>name && '\r' == *(pos1past-1)) // Windows
363363
--pos1past;
364-
return fmt::StringRef(name, pos1past - name);
364+
while (isspace(*name) && name < pos1past) // trim left
365+
++name;
366+
while (name < pos1past && isspace(*(pos1past-1))) // trim right
367+
--pos1past;
368+
if (name < pos1past)
369+
return fmt::StringRef(name, pos1past - name);
370+
else
371+
if (was_empty)
372+
*was_empty = true;
365373
}
366374
writer_.clear();
367375
if (index>=i2)
@@ -376,11 +384,11 @@ size_t mp::NameProvider::number_read() const {
376384
}
377385

378386
std::vector<std::string> mp::NameProvider::get_names(
379-
size_t n, size_t i2) {
387+
size_t n, size_t i2, bool* any_empty) {
380388
std::vector<std::string> result;
381389
result.reserve(n);
382390
for (size_t i=0; i<n; ++i)
383-
result.push_back(name(i, i2));
391+
result.push_back(name(i, i2, any_empty));
384392
return result;
385393
}
386394

src/scip/reader_nl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3243,7 +3243,7 @@ SCIP_RETCODE SCIPincludeReaderNl(
32433243
"reading/" READER_NAME "/comments", "should comments be written to nl files",
32443244
NULL, FALSE, FALSE, NULL, NULL) );
32453245

3246-
SCIP_CALL( SCIPincludeExternalCodeInformation(scip, "AMPL/MP 4.0.3", "AMPL .nl file reader library (github.com/ampl/mp)") );
3246+
SCIP_CALL( SCIPincludeExternalCodeInformation(scip, "AMPL/MP 4.0.4", "AMPL .nl file reader library (github.com/ampl/mp)") );
32473247

32483248
return SCIP_OKAY;
32493249
}

0 commit comments

Comments
 (0)