From haroldo.santos at gmail.com Sat Nov 25 18:16:45 2017
From: haroldo.santos at gmail.com (Haroldo Santos)
Date: Sat, 25 Nov 2017 21:16:45 -0200
Subject: [CyLP] CyLP and CBC Trunk
Message-ID:
Hi,
I tried to compile CyLP with CBC Trunk.
Only one modification was required to make it work, to include the header
CoinTypes.hpp
in the source
cylp/cy/CyCoinModel.cpp
Maybe someone could fix this is CyLP trunk ?
Cheers,
Haroldo
--
=============================================================
Haroldo Gambini Santos
Computing Department
Universidade Federal de Ouro Preto - UFOP
email: haroldo [at ] iceb.ufop.br
home/research page: www.decom.ufop.br/haroldo
It has long been an axiom of mine that the little things are infinitely
the most important.
-- Sir Arthur Conan Doyle, "A Case of Identity"
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From haroldo.santos at gmail.com Sat Nov 25 19:47:18 2017
From: haroldo.santos at gmail.com (Haroldo Santos)
Date: Sat, 25 Nov 2017 22:47:18 -0200
Subject: [CyLP] Working with matrices of variables
Message-ID:
Hi,
I'm trying to learn how to create models in CyLP.
My first attempt was to solve the n-queens puzzle.
I need a way to create a matrix of binary variables indicating if there is
a queen at each cell.
Basic constraints are those restricting one queen per row and per column.
Since the example in CyLP adds a list of variables, my first idea was to
create a list of variables and iterate some parts of this list to create
constraints. It failed because it seems and CyLP variables can't be
iterated in the same way of python lists. How can I retrieve a range of
some variables to add in constraints ? Is there a more elegant way of
implementing these simple constrains ? Thanks !
Follows my bugged example:
import numpy as np
from cylp.cy import CyClpSimplex
from cylp.py.modeling.CyLPModel import CyLPArray
n = 8
s = CyClpSimplex()
x = s.addVariable( 'x', n*n, True )
xrow = []*n
for i in range(n):
xrow[i] = x[i*n:i*n+n]
for i in range(n):
s += (CyLPArray([1]*n)) * xrow[i] == 1
s.writeLp('a.lp')
--
=============================================================
Haroldo Gambini Santos
Computing Department
Universidade Federal de Ouro Preto - UFOP
email: haroldo [at ] iceb.ufop.br
home/research page: www.decom.ufop.br/haroldo
It has long been an axiom of mine that the little things are infinitely
the most important.
-- Sir Arthur Conan Doyle, "A Case of Identity"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: