Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue when combining add_linear_constraints and add_min_set_objective #223

Closed
ninzyfb opened this issue Jan 21, 2022 · 2 comments
Closed
Labels

Comments

@ninzyfb
Copy link

ninzyfb commented Jan 21, 2022

Hi there, thanks in advance for your help with this issue,

I am having a strange error come up which i think may be a result of me misunderstanding what add_linear_constraint() does.

I have a planning surface which represents the South African EEZ at 10 x 10 km resolution. The raster is made up of 26216 cells, 10809 of which have a value of 1. I want a solution to my conservation problem which only keeps a maximum of 10% of the planning units, which is 1080 cells (to achieve a 10% total area protection of the EEZ).

I am using a raster stack of 48 biodiversity feature layers which are shark and ray distribution maps, each raster layer has values ranging from 0 to 1 (probability of occurrence) within the EEZ.

Finally i have tailored targets for each biodiversity feature.

However a problem arises when i raise my targets. If i use a targets vector with low targets and each target set at either 0.2, 0.3 or 0.4 then gurobi can solve the problem. But when i use a targets vector with medium targets set at either 0.3, 0.4, or 0.5 i get this error: "Error in .local(a, b = b, ...) : no solution found (e.g. due to problem infeasibility or time limits)". Which is very strange as the coverage summary with low targets are well above what i am asking so i wouldn't except raising each target by 0.1 to make the problem that much more complex. So i am not sure what is going wrong?

Below is how i have set my problem:

problem_single = problem(pu,features) %>% # costs and features
add_min_set_objective() %>%
add_linear_constraints(threshold = 1080,sense = "<=",data = pu)%>%
add_relative_targets(t) %>%
add_binary_decisions() %>%
add_gurobi_solver()

This is the problem when i have low targets:

problem_single
Conservation Problem
planning units: RasterLayer (10809 units)
cost: min: 1, max: 1
features: ACROTERIOBATUS_ANNULATUS_Aseasonal_res10_ensemblemean, AETOMYLAEUS_BOVINUS_Aseasonal_res10_ensemblemean, BATHYRAJA_SMITHII_Aseasonal_res10_ensemblemean, ... (48 features)
objective: Minimum set objective
targets: Relative targets [targets (min: 0.2, max: 0.4)]
decisions: Binary decision
constraints: <Linear constraints [threshold (1080)]>
penalties: <Boundary penalties [edge factor (min: 0.5, max: 0.5), penalty (0), zones]>
portfolio: default
solver: Gurobi [first_feasible (0), gap (0.1), node_file_start (-1), numeric_focus (0), presolve (2), threads (1), time_limit (2147483647), verbose (1)]

This is the problem when i have medium targets:

problem_single
Conservation Problem
planning units: RasterLayer (10809 units)
cost: min: 1, max: 1
features: ACROTERIOBATUS_ANNULATUS_Aseasonal_res10_ensemblemean, AETOMYLAEUS_BOVINUS_Aseasonal_res10_ensemblemean, BATHYRAJA_SMITHII_Aseasonal_res10_ensemblemean, ... (48 features)
objective: Minimum set objective
targets: Relative targets [targets (min: 0.3, max: 0.5)]
decisions: Binary decision
constraints: <Linear constraints [threshold (1080)]>
penalties: <Boundary penalties [edge factor (min: 0.5, max: 0.5), penalty (0), zones]>
portfolio: default
solver: Gurobi [first_feasible (0), gap (0.1), node_file_start (-1), numeric_focus (0), presolve (2), threads (1), time_limit (2147483647), verbose (1)]

@ricschuster
Copy link
Member

Hi @ninzyfb,
Thanks for reaching out about this.

It looks like the problem is that with medium targets, the solver can't find a solution, because what you ask it to do is not possible.

My guess would be that the low target scenario can be solved with 1080 pu's or less. Once you increase the target with min set, a solution would have to include >1080 pu's, which is why you get the error message.

Using the min_set objective function, you have constraints related to features and you also add a constraint with the add_linear_constraint function. Both constraint types will need to be met in order to find a solution.

In your case the question is: which constraint type is more important to keep? Do you really need to capture each feature representation to its targets value or is the area budget a hard cap at 1080 cells?

Because you can't do both, you have two options:

  1. accept features might not meet their targets:
    Here you can use the add_min_shortfall_objective objective or other budget driven objective functions. You will still add your targets and can explore add_feature_weights to make sure feature representation is well spread out across features or very important ones get higher weight.

  2. accept that the solution could go over 1080 cells:
    Here you could stay with min_set, but drop the linear constraint. You could add add_linear_penalties to ensure that only certain pu's get selected. This isn't quite what you were after with the linear constraint, but I thought I'd mention it here.

Does that make sense?

@ninzyfb
Copy link
Author

ninzyfb commented Jan 25, 2022

Hi Richard,

Thank you for your suggestions. It makes sense and i think the min_shorftall_objective with feature weights might be the way to go. I will close this issue however as i am now also discussing this problem further in my other issue and it might get confusing to have two running in parallel.

Thanks!

@ninzyfb ninzyfb closed this as completed Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants