Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Last active December 4, 2017 20:05
Show Gist options
  • Save sergiolucero/49a44be98d220d19e28b52ed700b8c93 to your computer and use it in GitHub Desktop.
Save sergiolucero/49a44be98d220d19e28b52ed700b8c93 to your computer and use it in GitHub Desktop.
calling IBM CPLEX
from forestry import ForestryLinearProgram # this is project-specific
from PuLP.solvers import CBC # open-source LinearProgramming library and solver
from creds import BASE_URL, API_KEY # these are used to id with IBM
from docloud.job import JobClient
my_problem = ForestryLinearProgram('forestry_test.xlsx') # input file contains all relevant tree data
#my_problem.solve(CBC) # this is how we used to work, until our problems grew too big for open-source
my_problem.save_to_MPS('forestry_LP.mps') # here we export to a format that IBM CPLEX can recognize
client = JobClient(BASE_URL, API_KEY)
resp = client.execute(input = 'forestry_LP.mps', output = 'solution.json')
@fanyang-ceg
Copy link

how to output the x values in the json?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment