R Under development (unstable) (2023-04-23 r84305 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library(rcdd) If you want correct answers, use rational arithmetic. See the Warnings sections in help pages for functions that do computational geometry. > > A <- rbind( + c(0, 1.000, -1, 0, 0, 0), + c(0, 1.000, -1, 0, 0, 0), + c(0, -0.001, 1, 0, 0, 0), + c(0, -0.001, 0, 1, 0, 0), + c(0, -0.001, 0, 0, 1, 0), + c(0, -0.001, 0, 0, 0, 1), + c(1, 1.000, -1, -1, -1, -1), + c(1, 0.300, -1, -1, -1, 0), + c(1, 7.990, -1, -3, -5, -8)) > > b <- c(0, 0, 0, 0) > > out <- lpcdd(A, b) > out $solution.type [1] "Inconsistent" $dual.direction [1] 0 0 4 2 0 0 8 -3 -1 > > all(A[out$dual.direction < 0, 1] == 1) [1] TRUE > > fred <- rbind(out$dual.direction) %*% A > fred <- as.numeric(fred) > sally <- fred[2] > fred <- fred[- c(1, 2)] > all.equal(max(abs(fred)), 0) [1] TRUE > > sally >= 0 [1] FALSE > ### if FALSE proves the constraints cannot be satisfied > > > Arat <- 1000 * A > Arat <- round(Arat) > Arat <- z2q(Arat, 0 * Arat + 1000) > Arat [,1] [,2] [,3] [,4] [,5] [,6] [1,] "0" "1" "-1" "0" "0" "0" [2,] "0" "1" "-1" "0" "0" "0" [3,] "0" "-1/1000" "1" "0" "0" "0" [4,] "0" "-1/1000" "0" "1" "0" "0" [5,] "0" "-1/1000" "0" "0" "1" "0" [6,] "0" "-1/1000" "0" "0" "0" "1" [7,] "1" "1" "-1" "-1" "-1" "-1" [8,] "1" "3/10" "-1" "-1" "-1" "0" [9,] "1" "799/100" "-1" "-3" "-5" "-8" > > brat <- d2q(b) > brat [1] "0" "0" "0" "0" > > out.rat <- lpcdd(Arat, brat) > out.rat $solution.type [1] "Inconsistent" $dual.direction [1] "0" "0" "4" "2" "0" "0" "8" "-3" "-1" > > out$solution.type == out.rat$solution.type [1] TRUE > all.equal(out$dual.direction, q2d(out.rat$dual.direction)) [1] TRUE > > fred <- qmatmult(rbind(out.rat$dual.direction), Arat) > sally <- fred[2] > fred <- fred[- c(1, 2)] > all(fred == "0") [1] TRUE > > qsign(sally) >= 0 [1] FALSE > ### if FALSE proves the constraints cannot be satisfied > > > proc.time() user system elapsed 0.23 0.06 0.28