Skip to main content

SCOP is Solver for COnstraint Programing.

Project description

The myscop is wrapper of SCOP.

SCOP is Solver for COnstraint Programing.

Need scop and scop.py.

https://logopt.com/scop2/

Example(bin packing)

from myscop import MyModel, MyLinear as L

items = [6, 5, 4, 3, 1, 2]  # item size
num_bins = 3  # bin size
m = MyModel()
vv = m.addvars(len(items), range(num_bins))
for b in range(num_bins):
    m.addcons(L(items, vv, b) <= 7)
m.optimize()
ans = [v.value for v in vv]
print(ans)  # ['2', '0', '1', '1', '2', '0']

Example(alldiff & quadratic)

from myscop import MyModel, MyAlldiff as A, MyQuadratic as Q

m = MyModel()
x, y, z = m.addvars(3, range(3))
m.addcons(A([x, y, z]))
for i, j in [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]:
    for v1, v2 in zip([x, x, y], [y, z, z]):
        if (v1 == x and v2 == y and i == 1 and j == 0) or (
            v1 == y and v2 == z and i == 0 and j == 2
        ):
            continue
        m.addcons(Q(1, [v1], i, [v2], j))
m.optimize()
ans = [v.value for v in [x, y, z]]
print(ans)  # ['1', '0', '2']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

myscop-0.0.4-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file myscop-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: myscop-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.2 Windows/10

File hashes

Hashes for myscop-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3e69011b5ba1db964b098ddc43b6bb922f08f9daf0415f43db1a923346140994
MD5 2226126219eaf0b2aa7b50dc8236a651
BLAKE2b-256 a3a54e8dc8ca5fced974566cec2afea3f4fab27390ffdfff654d14e3292d6e21

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page