Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17419

Number of constraints is zero?

$
0
0

My code is:

from docplex.mp.model import Modelm = Model(name='allocation optimization')m1 = m.continuous_var_dict(keys=['y1-1', 'z1-1', 'w1-1', 'y1-2', 'z1-2', 'w1-2'], name=”1s_VN”)m1 = {”y1-1”: 1, „z1-1”: 2, „w1-1”: 4, „y1-2”: 1, „z1-2”: 2, „w1-2”: 4}m2 = m.continuous_var_dict(keys=['y2-1', 'z2-1', 'w2-1'], name=”2nd_VN”)m2 = {”y2-1”: 1, „z2-1”: 2, „w2-1”: 4}m3 = m.continuous_var_dict(keys=['y3-2', 'z3-2', 'w3-2'], name=”3rd_VN”)m3 = {”y3-2”: 1, „z3-2”: 2, „w3-2”: 4}l1 = m.continuous_var_dict(keys=['VN1', 'VN2', 'c1', 'p1', 'beta1'], name=”1s_link”)l1 = {”VN1”: m1, „VN2”: m2, „c1”: 4, „p1”: 5, „beta1”: 1}l2 = m.continuous_var_dict(keys=['VN1', 'VN2', 'c2', 'p2', 'beta2'], name=”2nd_link”)l2 = {”VN1”: m1, „VN2”: m3, „c2”: 4, „p2”: 5, „beta2”: 0.5}variables = [m1, m2, m3]for variable in variables:    keysList = list(variable.keys())    for key in keysList:        positive = m.add_constraint(variable[key] >= 0)

Despite of that when I use

m.print_information()

it prints

Model: allocation optimization

  • number of variables: 22
    • binary=0, integer=0, continuous=22
  • number of constraints: 0
    • linear=0
  • parameters: defaults
  • objective: none
  • problem type is: LP

How properly add constraints to dictionary elements?


Viewing all articles
Browse latest Browse all 17419

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>