lib/compsci/simplex/parse.rb in compsci-0.3.1.1 vs lib/compsci/simplex/parse.rb in compsci-0.3.2.1
- old
+ new
@@ -80,11 +80,15 @@
sym = matches[3].to_sym # consider matches[3].downcase.to_sym
return flt, sym
end
end
- def self.problem(maximize: nil, constraints: [], **kwargs)
+ def self.problem(**kwargs)
+ self.new(*self.get_params(**kwargs))
+ end
+
+ def self.get_params(maximize: nil, constraints: [], **kwargs)
if maximize
expr, maximize = maximize, true
elsif kwargs[:minimize]
expr, maximize = kwargs[:minimize], false
else
@@ -114,10 +118,10 @@
cofs << ineq_cofs[v]
}
a.push cofs
b.push rhs
}
- self.new(c, a, b)
+ [c, a, b]
end
def self.maximize(expression, *ineqs)
self.problem(maximize: expression, constraints: ineqs).solution
end