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

Implement the gurobi solver: current progress #25

Open
njtierney opened this Issue Jan 16, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@njtierney
Owner

njtierney commented Jan 16, 2017

else if(solver == "gurobi"){

    # In bar.R
        if (!requireNamespace("gurobi", quietly = TRUE)) {
            stop("Make sure that you have installed the Gurobi software and accompanying Gurobi R package, more details at https://www.gurobi.com/documentation/7.0/refman/r_api_overview.html")

    }
    # model <- list()
    # model$A          <- matrix(c(1,1,0,0,1,1), nrow=2, byrow=T)
    # model$obj        <- c(1,1,2)
    # model$modelsense <- "max"
    # model$rhs        <- c(1,1)
    # model$sense      <- c('<=', '<=')

    # J <- nrow(A)
    # I <- ncol(A)

    model <- list()

    # set A matrix
    model$A <- A

        Nx <- nrow(A)
        Ny <- ncol(A)
        N <- n_added

        # d <- [ones(1,Ny) zeros(1,Nx)];
        d <- c(rep(1, Ny), rep(0,Nx))
    # c <- -[zeros(Ny,1); ones(Nx,1)];
        # c <- c(rep(0, Ny), rep(1,Nx))
    model$obj <- c(rep(0, Ny), rep(1,Nx))

    model$modelsense <- "max"

        Aeq <- d

        beq <- N

        Ain <- cbind(-A, diag(Nx))

        bin <- matrix(rep(0,Nx), ncol = 1)

    # matrix of numeric constraint coefficients,
    # one row per constraint
    # one column per variable
        # constraint matrix??
    # constraint_matrix <- rbind(Ain, Aeq)
    # rhs_matrix <- rbind(bin, beq)
        model$rhs <- rbind(bin, beq)


    # model$sense      <- c('<=', '<=')
    model$sense <- c(rep("<=", Nx), "==")

    result <- gurobi::gurobi(model)

    return(result)

} # end gurobi

njtierney added a commit that referenced this issue Jan 20, 2017

@njtierney

This comment has been minimized.

Owner

njtierney commented Feb 15, 2017

Gurobi now works, however there are some remaining issues in #39, but these can be addressed there directly.

@njtierney njtierney added this to the 0.2.0 milestone Jul 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment