Giter VIP home page Giter VIP logo

Comments (11)

hongyuanjia avatar hongyuanjia commented on June 20, 2024

There is no non-standard evaluation (NSE) feature implemented in eplusr yet.
AAA1 is treated as normal IDF field name. But by using rlang package, I think you could achieve what you want. Considering this below:

library(rlang)
library(eplusr)

AAA1 <- "Gross_Rated_Cooling_COP";
model6012Try$"Coil:Cooling:DX:SingleSpeed"$Thermal_Zone_ComputerRoom1_Coil_Cooling_DX_Single_Speed$set_value(!!AAA1:=3.2);

Please note the using of !! and := which come from rlang package. I haven't try on my side yet as I can't access to my computer right now.

I am currently refactoring model editing functionalities to make $set_value() more programming friendly. Stay tuned for next release.

from eplusr.

BRC555 avatar BRC555 commented on June 20, 2024

from eplusr.

hongyuanjia avatar hongyuanjia commented on June 20, 2024

The images were not uploaded.

I would suggest to comment in GitHub Issues instead of directly replying using email in order to make sure the images can be displayed correctly.

from eplusr.

BRC555 avatar BRC555 commented on June 20, 2024

Thanks for your kind help!
These two are the missed pictures in the last section:
capture3
capture4

from eplusr.

BRC555 avatar BRC555 commented on June 20, 2024

I think there are some problems to use $set_value if some variables are used to replace the class, object or field.
Can u suggest any other alternative ways to set new value for a specific field in a object in a class, e.g. changing value in the "Default" column of the following screen shot?
capture5

Thanks a lot.

from eplusr.

hongyuanjia avatar hongyuanjia commented on June 20, 2024

Thanks for reporting that.

Thanks for your kind help!
These two are the missed pictures in the last section:
capture3
capture4

There are probably some bugs in $set_value(). It would be great if you could send me the debugging info by running traceback() after each error occurred. That will make it much easier for me to find where the problem was.


I think there are some problems to use $set_value if some variables are used to replace the class, object or field.
Can u suggest any other alternative ways to set new value for a specific field in a object in a class, e.g. changing value in the "Default" column of the following screen shot?
capture5

Thanks a lot.

Could you please send me the IDF file if there is no confidential concern? Then I can try on my side.

As for alternative ways to set values, you can use $set_object() in Idf class. As I don't have the model, just using an example file here to demonstrate:

library(eplusr)
library(data.table) # for reading input data

# taking this as an example
path_idf <- file.path(eplus_config(8.8)$dir, "ExampleFiles", "HospitalLowEnergy.idf")

idf <- read_idf(path_idf)

# read input data
input <- data.table::fread(
  "
  index , class             , object                                     , field , default , new_value
  1     , Coil:Heating:Fuel , Floor 1 Cafe Heat Pump Sup Heat Coil       , 4     , 0.8     , 0.7
  2     , Coil:Heating:Fuel , Floor 1 Clean Heat Pump Sup Heat Coil      , 4     , 0.8     , 0.6
  3     , Coil:Heating:Fuel , Floor 1 Conference Heat Pump Sup Heat Coil , 4     , 0.8     , 0.5
  4     , Coil:Heating:Fuel , Floor 1 Dining Heat Pump Sup Heat Coil     , 4     , 0.8     , 0.4
  "
)

# get target field names
input[, `:=`(field_name = idf$definition(class)[[1L]]$field_name(field)), by = index]

# get correct input value format for $set_object()
format_input_value <- function (field_name, value) {
  val <- list(value)
  names(val) <- field_name
  val
}

input[, `:=`(value = list(format_input_value(field_name, new_value))), by = index]

idf$set_object(object = input$object, value = input$value)

# check results
vapply(idf$object(input$object), function (obj) obj$get_value(4), list(1))
# $Floor_1_Cafe_Heat_Pump_Sup_Heat_Coil
# [1] 0.7
# 
# $Floor_1_Clean_Heat_Pump_Sup_Heat_Coil
# [1] 0.6
# 
# $Floor_1_Conference_Heat_Pump_Sup_Heat_Coil
# [1] 0.5
# 
# $Floor_1_Dining_Heat_Pump_Sup_Heat_Coil
# [1] 0.4
# 

from eplusr.

hongyuanjia avatar hongyuanjia commented on June 20, 2024

Also, please make sure to use the develop version as there was a bug in the CRAN version (v0.9.2) when updating value references (see #20).

You can install the develop version by doing:

devtools::install_github("hongyuanjia/eplusr")

from eplusr.

BRC555 avatar BRC555 commented on June 20, 2024

Also, please make sure to use the develop version as there was a bug in the CRAN version (v0.9.2) when updating value references (see #20).

You can install the develop version by doing:

devtools::install_github("hongyuanjia/eplusr")

Thanks,
I try to run "devtools::install_github("hongyuanjia/eplusr")"; But there is something wrong:
capture6

from eplusr.

hongyuanjia avatar hongyuanjia commented on June 20, 2024

Please restart R and RStudio and then do the installation.

You may also want to manually run install.packages(c("data.table", "lubridate")) as they failed to install automatically in your case.

from eplusr.

hongyuanjia avatar hongyuanjia commented on June 20, 2024

The new version of 0.9.3 has been landed on CRAN. You can install the latest version from CRAN which has already fixed the issue #20.

from eplusr.

hongyuanjia avatar hongyuanjia commented on June 20, 2024

In version v0.10.0, $set() in Idf and IdfObject class directly support inputs as lists. Close this.

from eplusr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.