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