ampl / amplpy

Python API for AMPL

Home Page:https://amplpy.ampl.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Benders Decomposition

ahmadanaqreh opened this issue · comments

I have seen a model related to Benders Decomposition about transportation location (just the .mod and .dat files) but I couldn't find the python file that runs the model, is it available somewhere?? Moreover, there is a slide talking about callback for the TSP problem in your slides: is the implementation available for that??
Thanks a lot

Thanks for reporting this issue. The example location transportation has been added in bb827e0. You can find the example at https://github.com/ampl/amplpy/blob/master/examples/locationtransportation.py.

Regarding the callbacks, they are in the repository https://github.com/ampl/ampls-api. You can find examples at https://github.com/ampl/ampls-api/tree/master/python/examples. You can find documentation at https://ampls.readthedocs.io/. Please note that this feature is still in beta.

Thank you so much for your help, I have another question please, now I am trying to run the example called simple_callback_gurobi.py here: https://github.com/ampl/ampls-api/blob/master/python/examples/simple_callback_gurobi.py
with amplpy-gurobi 0.1.0b6 I got an error "module 'amplpy_gurobi' has no attribute 'GurobiCallback " and when I am using amplpy-gurobi 0.1.0b8 the error is "DLL load failed while importing _amplpy_gurobi_swig: The specified module could not be found."

Thanks for reporting this issue. This issue has now been fixed in version amplpy-gurobi 0.1.0b10. The examples in ampls-api were also updated since simple_callback_gurobi.py in particular was outdated.

Thank you for your collaboration, I can see the new version, but on the same example there is this runtime error
"RuntimeError: Unknown exception
License file ampl.lic not found anywhere in $PATH.
gurobi (Windows AMD64), licchk(20131021), ASL(20190605)"

You need to have the path to the AMPL folder in your environment variable path before importing amplpy_gurobi. You can either set if on your system our do it in python as follows:

import os
os.environ["PATH"] += os.pathsep + r'C:/complete/path/to/ampl_mswin64/'
import amplpy_gurobi as ampls

Please note that this only works if you have an ampl license, it does not work if you have a time-limited bundle.

Version 0.1.0b17 of amplpy_gurobi and amplpy_cplex now work with both license files and time-limited bundles.