| 302 | |
| 303 | |
| 304 | LinearConstraint* LinearProgram::create_constraint( |
| 305 | LinearConstraint::BoundType bt /* = Variable::FREE */, |
| 306 | double lb /* = -Variable::infinity() */, |
| 307 | double ub /* = +Variable::infinity() */, |
| 308 | const std::string& name /* = "" */ ) |
| 309 | { |
| 310 | LinearConstraint* c = new LinearConstraint(this, bt, lb, ub); |
| 311 | |
| 312 | std::size_t idx = constraints_.size(); |
| 313 | c->set_index(idx); |
| 314 | |
| 315 | const std::string& fixed_name = name.empty() ? "c" + from_integer(idx, 9, '0') : name; |
| 316 | c->set_name(fixed_name); |
| 317 | |
| 318 | constraints_.push_back(c); |
| 319 | return c; |
| 320 | } |
| 321 | |
| 322 | |
| 323 | std::vector<LinearConstraint*> LinearProgram::create_n_constraints(std::size_t n) { |