title: TensorFlow - add variables (weights) constraint
body: <p>Just a toy example. Suppose we have 5 stocks and we want to find the best portfolio structure (linear weights) maximizing our PnL on history. Weights are used to build portfolio invested in equities.</p>
  
  <pre><code>weights = tf.Variable(np.random.random((5, 1)), dtype=tf.double)
  returns = tf.placeholder(dtype=tf.double)
  portfolio = tf.matmul(returns, weights)
  pnl = portfolio[-1]
  
  optimizer = tf.train.AdamOptimizer().minimize(-1*pnl)
  
  with tf.Session() as sess:
      sess.run(tf.global_variables_initializer())
      train_data = {returns: returns_data}  
      for i in range(100):
          sess.run(optimizer, feed_dict=train_data)
  </code></pre>
  
  <p>I want to find the best decision on history with following constraints:</p>
  
  <ul>
  <li>each stock individual weight (min: 0.05, max: 0.5)</li>
  <li>weights vector sum = 1 (portfolio is always invested)</li>
  </ul>
  
  <p>How can I implement weights constraints to the optimizer?</p>