# How to examine properties of a candidate solution vector to an optimization problem in JuMP?

**URL:** <https://discourse.julialang.org/t/how-to-examine-properties-of-a-candidate-solution-vector-to-an-optimization-problem-in-jump/92483>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [January 4, 2023, 5:00am UTC](https://discourse.julialang.org/t/how-to-examine-properties-of-a-candidate-solution-vector-to-an-optimization-problem-in-jump/92483 "2023-01-04T05:00:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samerb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samerb/32/9242_2.png) [@samerb](https://discourse.julialang.org/u/samerb)\
**Post date:** [January 4, 2023, 5:00am UTC](https://discourse.julialang.org/t/how-to-examine-properties-of-a-candidate-solution-vector-to-an-optimization-problem-in-jump/92483/1 "2023-01-04T05:00:21Z")

</div>

Suppose I am solving an optimization problem in JuMP (see example below), and I want to try out a candidate solution vectors to the problem and see what it’s objective value and constraint values it yields (in particular if they bind). Is there a standard way to do this in JuMP?

Obviously, I could just evaluate the objective and the constraint functions at the candidate solution separately without using JuMP. But it might be more convenient to be able to do all these evaluations with one line of code using a function of the JuMP model or something. Is this possible?

**Example** :

```julia
using JuMP

model = Model(optimizer_with_attributes(
            Ipopt.Optimizer))

function obj(x)
    return x^2
end

# Ex-post IC
function test_constraint(x)
    return x^3
end

register(model, :obj, 1, obj; autodiff = true)
register(model, :test_constraint, 1, test_constraint; autodiff = true)

@variable(model, x >= 0)
@NLconstraint(model, test_constraint(x) <= 5)
@NLobjective(model, Max, obj(x))

using Printf
set_silent(model)
optimize!(model);
status = @sprintf("%s", JuMP.termination_status(model));
if (status=="LOCALLY_SOLVED")
    @show value(x);
end

```

So for example, now I might want to try out x=3 and see what objective it gives and whether the constraint `x^3 <= 5` binds.

Thanks

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [January 4, 2023, 7:55am UTC](https://discourse.julialang.org/t/how-to-examine-properties-of-a-candidate-solution-vector-to-an-optimization-problem-in-jump/92483/2 "2023-01-04T07:55:26Z")

</div>

You might be able to make use of `primal_feasibility_report`, explained in the documentation here: [Checking feasibility of solutions](https://jump.dev/JuMP.jl/stable/manual/solutions/#Checking-feasibility-of-solutions)

To compute the value of the objective at a point, see: [Evaluate the objective function at a point](https://jump.dev/JuMP.jl/stable/manual/objective/#Evaluate-the-objective-function-at-a-point)
