Last active
December 4, 2017 20:05
-
-
Save sergiolucero/49a44be98d220d19e28b52ed700b8c93 to your computer and use it in GitHub Desktop.
calling IBM CPLEX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') |
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
This is a fairly standard linear program/problem in forestry. The Objective Function (1) seeks to maximize Z, which is defined as the total income generated by the decisions in vector x. This vector represents whether stand i is harvested in period j, and is binary (all or nothing). Each stand must be harvested at some point (2). Minimum (3) and maximum (4) volume constraints must be observed. Finally there is an area constraint (5) which we can ignore.