jeudi 18 novembre 2021

comparing a vector with a scalar

I am trying to write a function that will compare two matrix or list base on some parameters define in work. the first function check if x respect the differents contraints and the second function check is the answer one if better than the second. since the function is_sol_feasible return a vector when i run the function i received the following warning message: the condition has length > 1 and only the first element will be used

So i am wondering if any of you can help me with it? Thank you in advance!!!

'''
        is_sol_feasible <- function(x) {
          sat_c1(x) & sat_c2(x) & sat_c3(x) 
        }

        is_sol_x_better_than_y <- function(x,y) {
          sol_x_better = FALSE
          if (!is_sol_feasible(x)){
            sol_x_better = FALSE
          } else if (is_sol_feasible(x) & !is_sol_feasible(y)){
            sol_x_better = TRUE
'    # il s'agit de choisir la solution minimale'
          } else if (f(x) < f(y)) {
            sol_x_better = TRUE
          }
          sol_x_better
        }
'''

Aucun commentaire:

Enregistrer un commentaire