MCPcopy Create free account
hub / github.com/LiangliangNan/PolyFit / create_variable

Method create_variable

code/math/linear_program.cpp:273–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271
272
273Variable* LinearProgram::create_variable(
274 Variable::VariableType vt /* = Variable::CONTINUOUS */,
275 Variable::BoundType bt /* = Variable::FREE */,
276 double lb /* = -Variable::infinity() */,
277 double ub /* = +Variable::infinity() */,
278 const std::string& name /* = "" */)
279{
280 Variable* v = new Variable(this, vt);
281 v->set_bounds(bt, lb, ub);
282
283 std::size_t idx = variables_.size();
284 v->set_index(idx);
285
286 const std::string& fixed_name = name.empty() ? "x" + from_integer(idx, 9, '0') : name;
287 v->set_name(fixed_name);
288
289 variables_.push_back(v);
290 return v;
291}
292
293
294std::vector<Variable*> LinearProgram::create_n_variables(std::size_t n) {

Callers

nothing calls this directly

Calls 6

from_integerFunction · 0.85
set_boundsMethod · 0.80
sizeMethod · 0.45
set_indexMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected