View source: R/Disconnectivity.R
Disconnectivity_Add_Constraint | R Documentation |
Disconnectivity_Add_Constraint
creates a Disconnectivity Constraint in the optimization model of the form:
\sum (Condition) + C * Target \le C
,
where C
is the number of parcels in Condition
. This constraint means that the parcel Target
can be protected (invested)
only if none of the parcels in Condition
are protected (invested).
Disconnectivity_Add_Constraint(Target, Condition, Repetition = TRUE,
Silence=FALSE, Env= .GlobalEnv)
Target |
A string: the name of a parcel which can only be protected (invested) if none of the |
Condition |
A vector of strings: the names of the parcels that if at least one of them are protected (invested), the |
Repetition |
A binary parameter: If |
Silence |
A binary parameter: if |
Env |
the environment where the package should create or access variables. By default the package works in the R's Global environment. (Default: .GlobalEnv) |
When used for the first time, Disconnectivity_Add_Constraint
or
Disconnectivity_Import_Constraint will create a list named Disconnectivity
.
When, for the first time, a disconnectivity constraint is added for a Target
parcel, for instance named "Parcel_1",
a new member named "Parcel_1" will be added to the Disconnectivity
list, i.e. Disconnectivity[["Parcel_1"]]
.
Then, if Repetition=FALSE
, whenever Disconnectivity_Add_Constraint
or
Disconnectivity_Import_Constraint are used for "Parcel_1", the Condition
parcels will be added to "Parcel_1"'s
first disconnectivity constraint, i.e. Disconnectivity[["Parcel_1"]][[1]]
.
Otherwise, if Repetition=TRUE
, the Condition
parcels will create a new constraint for "Parcel_1", i.e.
Disconnectivity[["Parcel_1"]][[i+1]]
, where i
is the number of "Parcel_1"'s existing disconnectivity constraints.
Removing a specific disconnectivity constraint of a Target
: Disconnectivity constraint i
of a parcel named "Parcel_j"
can be removed using the following code:
Disconnectivity[["Parcel_j"]][[i]]<-NULL
Removing all disconnectivity constraints of a Target
: Disconnectivity constraints of a parcel named "Parcel_j"
can be removed using the following code:
Disconnectivity[["Parcel_j"]]<-NULL
Remove all Disconnectivity Constraints: All of the Disconnectivity constraints can be removed using the following code:
remove(Disconnectivity)
NULL (creates some variables in the environment but returns nothing)
Other Disconnectivity Constraints:
Disconnectivity_Import_Constraint()
Other Constraints:
Add_Constraint()
,
Budget_Add_Constraint()
,
Connectivity_Add_Constraint()
## Not run:
Disconnectivity_Add_Constraint(Target= "Parcel_1", Condition= "Parcel_4", Repetition=TRUE)
## will create Disconnectivity[["Parcel_1"]][[1]] and
add the following constraint to the optimization model
Parcel_4 + Parcel_1 <= 1 . Now, if the code ##
Disconnectivity_Add_Constraint(Target= "Parcel_1", Condition= c("Parcel_2","Parcel_3"),
Repetition=TRUE)
## is run, Disconnectivity[["Parcel_1"]][[2]] will be created,
and the following constraint will be added to the optimization model
Parcel_2 + Parcel_3 + 2*Parcel_1 <= 2 . However, if the code ##
Disconnectivity_Add_Constraint(Target= "Parcel_1", Condition= c("Parcel_2","Parcel_3"),
Repetition=FALSE)
## is run, only Disconnectivity[["Parcel_1"]][[1]] will be updated,
and its existing constraint will be updated in the optimization model as
Parcel_4 + Parcel_2 + Parcel_3 + 3*Parcel_1 <= 3 . ##
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.