eomahony / Numberjack

Python Combinatorial Optimisation Platform
http://numberjack.ucc.ie
GNU Lesser General Public License v2.1
157 stars 36 forks source link

Installing with SCIP on OSX #15

Closed slcott closed 10 years ago

slcott commented 10 years ago

I've been trying for the past few hours to install Numberjack with SCIP on OSX for the past few hours. I'm trying very hard to follow the directions exactly, but I am invoking sudo make and sudo make install rather than make and make install

cd ./solvers/sat; make install_python
cd ./python; python /Users/scott/Applications/Numberjack/solvers/sat/../../tools/setup.py install
running install
running build
running build_py
running install_lib
running install_egg_info
Removing /Library/Python/2.7/site-packages/NumberjackSatWrapper-1.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/NumberjackSatWrapper-1.0-py2.7.egg-info
cd ./solvers/mip; make install_python
cd ./python; python /Users/scott/Applications/Numberjack/solvers/mip/../../tools/setup.py install   
running install
running build
running build_py
running install_lib
running install_egg_info
Removing /Library/Python/2.7/site-packages/NumberjackMipWrapper-1.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/NumberjackMipWrapper-1.0-py2.7.egg-info
cd ./solvers/minisat; make install_python
cd ./python; python /Users/scott/Applications/Numberjack/solvers/minisat/../../tools/setup.py install   
running install
running build
running build_py
running install_lib
running install_egg_info
Removing /Library/Python/2.7/site-packages/NumberjackMiniSat-1.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/NumberjackMiniSat-1.0-py2.7.egg-info
cd ./solvers/mistral; make install_python
cd ./python; python /Users/scott/Applications/Numberjack/solvers/mistral/../../tools/setup.py install   
running install
running build
running build_py
running install_lib
running install_egg_info
Removing /Library/Python/2.7/site-packages/NumberjackMistral-1.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/NumberjackMistral-1.0-py2.7.egg-info
cd ./solvers/mistral2; make install_python
cd ./python; python /Users/scott/Applications/Numberjack/solvers/mistral2/../../tools/setup.py install
running install
running build
running build_py
running install_lib
running install_egg_info
Removing /Library/Python/2.7/site-packages/NumberjackMistral2-1.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/NumberjackMistral2-1.0-py2.7.egg-info
cd ./solvers/scip; make install_python
find: illegal option -- n
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
Makefile:47: /make/make.project: No such file or directory
find: illegal option -- n
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
find: illegal option -- n
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
make[1]: *** No rule to make target `/make/make.project'.  Stop.
make: *** [scip_install] Error 2

Then I try to test the installation with:

#!/usr/bin/python
# -*- coding: utf-8 -*-

from Numberjack import *

def model_warehouse_planning(data):
    WareHouseOpen = VarArray(data.NumberOfWarehouses)

    ShopSupplied = Matrix(data.NumberOfWarehouses,
                          data.NumberOfShops)

    # Cost of running warehouses
    warehouseCost = Sum(WareHouseOpen, data.WareHouseCosts)

    # Cost of shops using warehouses
    transpCost = Sum([ Sum(varRow, costRow) 
                       for (varRow, costRow) in zip(ShopSupplied, data.SupplyCost)])

    obj = warehouseCost + transpCost

    model = Model(
        # Objective function
        Minimise(obj), 
        # Channel from store opening to store supply matrix
        [[var <= store for var in col] 
         for (col, store) in zip(ShopSupplied.col, WareHouseOpen)],
        # Make sure every shop if supplied by one store
        [Sum(row) == 1 for row in ShopSupplied.row],
        # Make sure that each store does not exceed it's supply capacity
        [Sum(col) <= cap 
         for (col, cap) in zip(ShopSupplied.col, data.Capacity)]
    )

    return (obj, WareHouseOpen, ShopSupplied, model)

def solve_warehouse_planning(data, param):
    (obj, WareHouseOpen, ShopSupplied, model) = model_warehouse_planning(data)
    solver = model.load(param['solver'])
    solver.setVerbosity(1)
    solver.solve()    
    print obj.get_value()
    print "",WareHouseOpen
    print ShopSupplied

class WareHouseData:
    def __init__(self):        
        self.NumberOfWarehouses = 5
        self.NumberOfShops = 10
        self.FixedCost = 30
        self.WareHouseCosts = [30, 30, 30, 30, 30]
        self.Capacity = [1,4,2,1,3]
        self.SupplyCost = supplyCost = [
            [ 20, 24, 11, 25, 30 ],
            [ 28, 27, 82, 83, 74 ],
            [ 74, 97, 71, 96, 70 ],
            [ 2, 55, 73, 69, 61 ],
            [ 46, 96, 59, 83, 4 ],
            [ 42, 22, 29, 67, 59 ],
            [ 1, 5, 73, 59, 56 ],
            [ 10, 73, 13, 43, 96 ],
            [ 93, 35, 63, 85, 46 ],
            [ 47, 65, 55, 71, 95 ]
        ]

if __name__ == '__main__':
    solve_warehouse_planning(WareHouseData(), input({'solver':'SCIP'}))

which results in the following error:

new-host:Desktop scott$ python nj_scip_test.py
Traceback (most recent call last):
  File "nj_scip_test.py", line 68, in <module>
    solve_warehouse_planning(WareHouseData(), input({'solver':'SCIP'}))
  File "nj_scip_test.py", line 39, in solve_warehouse_planning
    solver = model.load(param['solver'])
  File "/Library/Python/2.7/site-packages/Numberjack.py", line 861, in load
    raise ImportError("ERROR: Failed during import, wrong module name? (%s)" % library)
ImportError: ERROR: Failed during import, wrong module name? (SCIP)

What am I doing wrong here?

9thbit commented 10 years ago

Hi @slcott, You must download the source code for the SCIP solver separately from http://scip.zib.de/#download Once you've downloaded the code, extract it: tar zxf scipoptsuite-?.?.?.tgz. Then cd into the directory and extract the SCIP and SoPlex code:

cd scipoptsuite-3.1.0/
tar zxf scip-?.?.?.tgz
tar zxf soplex-?.?.?.tgz

You then need to set an environment variable to tell Numberjack where to find SCIP: export ZIBPATH=path_to/scipoptsuite-3.1.0. The error Makefile:47: /make/make.project: No such file or directory means that the path to the SCIP Optimization Suite was not set.

You should never run sudo make just make then sudo make install. If you still get the above error, then run sudo -E make install, the -E maintains the environmental variables.