Skip to content
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

Error while reading the parameter "funit" from SISSO.in #72

Closed
dywu101 opened this issue Nov 12, 2024 · 7 comments
Closed

Error while reading the parameter "funit" from SISSO.in #72

dywu101 opened this issue Nov 12, 2024 · 7 comments

Comments

@dywu101
Copy link

dywu101 commented Nov 12, 2024

I am trying to run the regression example in folder input_templates, and I get this error message,

Error: Cannot read the parameter "funit"

The version of repository I used is SISSO.3.5, commit bf5d691.

Bug Reproduction

mkdir demo
cp input_templates/SISSO.in ./demo
cp input_templates/train.dat_regression ./demo/train.dat
cd ./demo
SISSO

Then you will get the same error message.
Comment funit sentence in SISSO.in will cancel error output, but I want to control units of features. So, it's not a feasible solution.

! funit=(1:2)(3:3)

Files

SISSO.in

!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
! Texts after a exclamation mark (!) are comments
! The (R), (C) and (R&C) denotes the keyword used by regression, classification, and both, respectively.
! A complete list and more explanations on these keywords can be found in the SISSO_Guide.pdf
! The setting below is just an example, and user may need to change them for their jobs.
!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ptype=1                !Property type 1: regression, 2:classification.
ntask=1                !(R&C) Multi-task learning (MTL) is invoked if >1.
scmt=.false.           !(R) Sign-Constrained MTL is invoked if .true.
desc_dim=2             !(R&C) Dimension of the descriptor/model.
nsample=5              !(R) Number of samples in train.dat. Set nsample=N1,N2,... for MTL.
!nsample=(n1,n2,...)   !(C) Number of samples. Set nsample=(n1,n2,...),(m1,m2,...),... for MTL.
restart=0              !(R&C) 0: starts from scratch, 1: continues the job(progress in the file CONTINUE)

!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
! Feature construction (FC) and sure independence screening (SIS)
! Implemented operators:(+)(-)(*)(/)(exp)(exp-)(^-1)(^2)(^3)(sqrt)(cbrt)(log)(|-|)(scd)(^6)(sin)(cos)
! scd: standard Cauchy distribution
!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
fstore=1               !(R&C) Features storage in memory. 1: by data (fast); 2: by S-expression (low-memory)
nsf= 3                 !(R&C) Number of scalar features provided in the file train.dat
ops='(+)(-)(*)(/)'     !(R&C) Operators to be customized by user from the list shown above.
fcomplexity=3          !(R&C) Maximal feature complexity (# of operators in a feature), starting from 0.
funit=(1:2)(3:3)       !(R&C) Feature unit: (n1:n2), features from n1 to n2 in train.dat have the same unit
fmax_min=1e-3          !(R&C) The feature will be discarded if the max. abs. value in it is < fmax_min.
fmax_max=1e5           !(R&C) The feature will be discarded if the max. abs. value in it is > fmax_max.
nf_sis=50000           !(R&C) Number of features in each of the SIS-selected subspace.

!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
! Descriptor identification (DI) via sparse regression (SO)
!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
method_so= 'L0'        !(R&C) 'L0' or 'L1L0'(LASSO+L0). 'L0' is always recommended.
fit_intercept=.true.   !(R) Fit to a nonzero (.true.) or zero (.false.) intercept for the linear model.
metric= 'RMSE'         !(R) The metric for model selection in regression: RMSE or MaxAE (max absolute error)
nmodel=100             !(R&C) Number of the top-ranked models to output (see the folder 'Models')
isconvex=(1,1,...)     !(C) Each data group constrained to be convex domain, 1: YES; 0: NO
bwidth=0.001           !(C) Boundary tolerance for classification

train.dat_regression

materials    property  feature1  feature2  feature3
sample1       3.0862    0.8626    0.7043    0.6312
sample2       2.8854    0.7260    0.7818    0.6119
sample3       0.6907    0.4943    0.0044    0.4420
sample4       0.9902    0.0106    0.0399    0.9877
sample5       0.7242    0.0970    0.3199    0.5504
@dywu101 dywu101 closed this as completed Nov 12, 2024
@dywu101 dywu101 reopened this Nov 12, 2024
@dywu101
Copy link
Author

dywu101 commented Nov 12, 2024

Try to Fix

Obviously, this bug is triggered by funit=(1:2)(3:3) in SISSO.in. To get more error message, I modify SISSO.f90,

! funit
feature_units=0.d0  ! default
if(index(funit_line,'(')/=0) then
  print *, 'nunit=', nunit
  do ll=1,nunit
    i=index(funit_line,'(')
    j=index(funit_line,':')
    kk=index(funit_line,')')
    print *, 'i,j,kk=',i,j,kk
    if((i+1)>(j-1)) goto 10041
    if((j+1)>(kk-1)) goto 10042
    if(i>0 .and. j>0) then
      read(funit_line(i+1:j-1),*,err=10043) k
      read(funit_line(j+1:kk-1),*,err=10044) l
      feature_units(ll,k:l)=1.d0
      funit_line(:kk)=''
    end if
  end do
end if

inquire(file='feature_units',exist=fexist) ! detect if the file 'feature_units' exists
if(fexist) then
  open(1,file='feature_units',status='old')
  do i=1,nsf
     read(1,*) feature_units(:,i)   ! unit of each feature represented by a vector (row)
  end do
  close(1)
end if

return
1002 print *, 'Error: Cannot read the parameter "nsample"'; stop
1003 print *, 'Error: Cannot read the parameter "isconvex"'; stop
10031 print *, 'Error: Cannot read the parameter "ops"'; stop
1004 print *, 'Error: Cannot read the parameter "funit"'; stop

10041 print *, '10041 Error: Cannot read the parameter "funit"'; stop
10042 print *, '10042 Error: Cannot read the parameter "funit"'; stop
10043 print *, '10043 Error: Cannot read the parameter "funit"'; stop
10044 print *, '10044 Error: Cannot read the parameter "funit"'; stop

recompiler a debug binary called SISSO.debug,

mpiifx -O2 var_global.f90 libsisso.f90 DI.f90 FC.f90 FCse.f90 SISSO.f90 -o SISSO.debug

Rerun the regression example with two different funit parameters, and get debug information like this,

$ grep funit SISSO.in   
funit=(1:2)(3:3)
#     1 3 56 8 0
$ SISSO.debug
 nunit=           3
 i,j,kk=                     1                     3                     5
 i,j,kk=                     6                     8                    10
 i,j,kk=                     0                     0                     0
 10041 Error: Cannot read the parameter "funit"

$ grep funit SISSO.in
funit=(1:1)(2:2)(3:3)
#     1 3 56 8 01 3 5
$ SISSO.debug
 nunit=           4
 i,j,kk=                     1                     3                     5
 i,j,kk=                     6                     8                    10
 i,j,kk=                    11                    13                    15
 i,j,kk=                     0                     0                     0
 10041 Error: Cannot read the parameter "funit"

The debug message above suggests this bug is caused by end of string funit_line, which makes variablesi,j,kk to go out of bounds. Finally program stops at error branch if((i+1)>(j-1)) goto 10041.

My solution is to reduce nunit by 1,

!do ll=1,nunit
 do ll=1,nunit-1 

this solution works well for me and no error occurs anymore. but I am NOT sure if this fix will work for other tests.
Is there any way to fix this bug without changing source code? maybe some parameters in SISSO.in can solve this problem?

@rouyang2017
Copy link
Owner

Hi, I have tried with exactly your SISSO.in and train.dat, and it finished without any error.

@dywu101
Copy link
Author

dywu101 commented Nov 13, 2024

Thank you for your reply.

This problem DO exist for me. Possible reasons include:

  1. What version are you using? I am using the latest repository on your github (commit bf5d691).
    Because you are a developer, you may use an unreleased repository at your local machine. Please check your git commit hash.
  2. Do you include this line funit=(1:2)(3:3) in SISSO.in? If you comment this line, the error message will not show up.

I tried again from scratch (clone, compiler and run), and got exactly the same error message. Here is my process:

image

It wouldn't be better if you could try again. Thank you very much.

@rouyang2017
Copy link
Owner

Following exactly your steps, I still get it run successfully (see below). The only difference between us is the compiler, otherwise I don't know why it fails in your case.
1731491755088

@dywu101
Copy link
Author

dywu101 commented Nov 13, 2024

Yes, it's a compiler issue. Using mpiifort instead of mpiifx will eliminate this problem. Thanks a lot.

@dywu101 dywu101 closed this as completed Nov 13, 2024
@linzihan322
Copy link

@rouyang2017 Unfortunately, ifort was removed in latest version, which means ifx has to be used (and produce this problem!).
image

@linzihan322
Copy link

linzihan322 commented Dec 29, 2024

@dywu101 I compiled and conducted some tests with ifx and found an interesting thing. I just add a single print, and nunit value is correct (same value as compiled with ifort).

case('funit')
     read(line_short(i+1:),'(a)',err=1001) funit_line
     if(index(funit_line(k+1:),'(')>0) nunit=0
     k=0
     do while (index(funit_line(k+1:),'(')>0)  ! calculate the nunit
       k=index(funit_line(k+1:),'(')+k
       nunit=nunit+1
       print *, 'k=',k,'nunit=',nunit ! Add this line 
     end do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants