Closed nikozara closed 2 years ago
"Very simple problem: minimize x while keeping x greater than 1." from gpkit import Variable, Model
x = Variable("x")
constraints = [x >= 1]
objective = x
m = Model(objective, constraints)
sol = m.solve(verbosity=0)
print("Optimal cost: %.4g" % sol["cost"]) print("Optimal x val: %.4g" % sol["variables"][x])
Closing as possible mistakenly created ticket, please feel free to re-open if there's a specific issue to report.
"Very simple problem: minimize x while keeping x greater than 1." from gpkit import Variable, Model
Decision variable
x = Variable("x")
Constraint
constraints = [x >= 1]
Objective (to minimize)
objective = x
Formulate the Model
m = Model(objective, constraints)
Solve the Model
sol = m.solve(verbosity=0)
print selected results
print("Optimal cost: %.4g" % sol["cost"]) print("Optimal x val: %.4g" % sol["variables"][x])