Disconnectivity_Add_Constraint: Create a Disconnectivity Constraint

Description Usage Arguments Details Value See Also Examples

View source: R/Disconnectivity.R

Description

Disconnectivity_Add_Constraint creates a Disconnectivity Constraint in the optimization model of the form:
∑ (Condition) + C * Target ≤ 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).

Usage

1
2
Disconnectivity_Add_Constraint(Target, Condition, Repetition = TRUE,
                                      Silence=FALSE, Env= .GlobalEnv)

Arguments

Target

A string: the name of a parcel which can only be protected (invested) if none of the Condition parcels are protected (invested).

Condition

A vector of strings: the names of the parcels that if at least one of them are protected (invested), the Target cannot be protected (invested).

Repetition

A binary parameter: If TRUE, the Condition parcels will create a new constraint for Target. If FALSE, the Condition parcels will be added to the first existing disconnectivity constraint of Target, i.e. Disconnectivity[["Target"]][[1]]. (Default: TRUE)

Silence

A binary parameter: if FALSE, the function will report a summary message. If TRUE, the function will be silent. (Default: FALSE)

Env

the environment where the package should create or access variables. By default the package works in the R's Global environment. (Default: .GlobalEnv)

Details

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)

Value

NULL (creates some variables in the environment but returns nothing)

See Also

Other Disconnectivity Constraints: Disconnectivity_Import_Constraint()

Other Constraints: Add_Constraint(), Budget_Add_Constraint(), Connectivity_Add_Constraint()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## 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)

paymanghasemi/SiteOpt documentation built on April 8, 2021, 3:44 a.m.