-
Notifications
You must be signed in to change notification settings - Fork 13
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
Can I use variable for Field in set_value? #21
Comments
There is no non-standard evaluation (NSE) feature implemented in eplusr yet. 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 I am currently refactoring model editing functionalities to make |
Dear Hongyuan:
Thanks a lot for your kind help!
I tried your way, but there is some error:
[cid:image001.png@01D45E66.E25D56B0]
I tried this way:
aaa="Coil:Cooling:DX:SingleSpeed";
aaa2=paste('"', aaa, '"', sep = "", collapse = ", ");
ObNaChange2= "Thermal_Zone_ComputerRoom1_Coil_Cooling_DX_Single_Speed";
FieldRealName="Gross_Rated_Cooling_COP";
OpResult=99;
eval(parse(text=paste0('model6012Try$',aaa2,'$',ObNaChange2,'$set_value(',FieldRealName,'=',OpResult,')')))
But sometime is OK and sometimes there is error like this:
[cid:image003.png@01D45E67.84295250]
Do you have other suggestions?
Our group is trying to use R to optimize a bunch of parameters values in EnergyPlus. So I am setting the variables to get and send the values directly in the optimization loop.
Thanks,
Borui CUI, Ph.D.
R&D Associate Staff, Oak Ridge National Laboratory
Oak Ridge, TN 37831-6324
Tel: (865) 241-3773 (Office), (865) 299-8596 (Cell)
cuib@ornl.gov<mailto:cuib@ornl.gov>
From: Hongyuan Jia <notifications@github.com>
Sent: Saturday, October 06, 2018 4:37 AM
To: hongyuanjia/eplusr <eplusr@noreply.github.com>
Cc: Cui, Borui <cuib@ornl.gov>; Author <author@noreply.github.com>
Subject: Re: [hongyuanjia/eplusr] Can I use variable for Field in set_value? (#21)
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#21 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ap1NBWNdMSOSOmPKxdwIAE3cosrdholAks5uiGuvgaJpZM4XI1Xv>.
|
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. |
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, |
Please restart R and RStudio and then do the installation. You may also want to manually run |
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. |
In version v0.10.0, |
For my case, I can change the value of a field like this:
model6012Try$"Coil:Cooling:DX:SingleSpeed"$Thermal_Zone_ComputerRoom1_Coil_Cooling_DX_Single_Speed$set_value("Gross_Rated_Cooling_COP"=1.2)
Or
model6012Try$"Coil:Cooling:DX:SingleSpeed"$Thermal_Zone_ComputerRoom1_Coil_Cooling_DX_Single_Speed$set_value(Gross_Rated_Cooling_COP=2.2)
But I cannot do like this in a loop which automatically get the field name from a csv file:
AAA1="Gross_Rated_Cooling_COP";
model6012Try$"Coil:Cooling:DX:SingleSpeed"$Thermal_Zone_ComputerRoom1_Coil_Cooling_DX_Single_Speed$set_value(AAA1=3.2);
Could I know any solution for my case?
Thanks a lot.
The text was updated successfully, but these errors were encountered: