Gurobi - Python组合优化:添加库存浓度限制

时间:2016-11-19 17:42:20

标签: gurobi

我试图在下面的Ipython Gurobi笔记本中添加库存浓度限制。我以为它会是[m.addConstr(portvars)< = 0.15," limit")];但我收到一条错误消息(见下面的消息)。任何人都知道如何添加浓度限制?

https://anaconda.org/mcg/markowitz/notebook

TypeError:不支持的操作数类型 - :' bool'和' NoneType'

1 个答案:

答案 0 :(得分:0)

Model.addConstr()会占用<?php // database connection include 'pdo_config.php'; try { // new pdo connection $conn = new PDO($dsn, $user, $pass, $opt); // post data $date = $_POST['date']; $duration = $_POST['duration']; // Note that the explode only works well if user inputs one blank space to separate the name // You can try to improve the separation method or better use two different inputs in the form $nameArray = explode(" ", $_POST['member_name']); $first_name = $nameArray[0]; $last_name = $nameArray[1]; $statement = $conn->prepare("SELECT member_id FROM members WHERE first_name = :first_name AND last_name = :last_name"); $statement->execute(array(':fisrt_name' => $first_name, ':last_name' => $last_name)); $row = $statement->fetch(); $member_id = $row['member_id']; // prepare statement and bind parameters $stmt = $conn->prepare("INSERT INTO games (date, duration, member_id) VALUES (:date, :duration, :member_id)"); $stmt->bindParam(':date', $date); $stmt->bindParam(':duration', $duration); $stmt->bindParam(':member_id', $member_id); // execute statement $stmt->execute(); // success or error message echo "New record created successfully"; } catch(PDOException $e) { echo "Error: " . $e->getMessage(); } $conn = null; ?> 个对象,因此您可能希望编写类似TempConstr的内容。