Skip to content

Implement CalculateBidPrice() functionality in Enrichment, Fuel_fab, and Source - #656

Closed
dean-krueger wants to merge 3 commits into
cyclus:mainfrom
dean-krueger:add-calc-unit-price
Closed

Implement CalculateBidPrice() functionality in Enrichment, Fuel_fab, and Source#656
dean-krueger wants to merge 3 commits into
cyclus:mainfrom
dean-krueger:add-calc-unit-price

Conversation

@dean-krueger

Copy link
Copy Markdown
Contributor

Summary of Changes

The functionality added by the CalculateBidCost()/CalculateBidPrice() functions was added to a few Cycamore facilities to open a wider conversation about the best way to implement this.

Related CEPs and Issues

This PR is related to:

Associated Developers

None.

Design Notes

There are a few areas where I think this COULD be improved by some cleverness, but there are also some areas where I think a wider discussion about the way this is implemented generally could be good, so I didn't spend too long trying to make the code that may need to be changed anyway super slick.

Testing and Validation

Built and tested Cyclus on my local machine. No tests were added, but I imagine some will be necessary.

Checklist

  • Read the Contributing to Cyclus guide.
  • Compile and run locally.
  • Add or update tests.
  • Document if needed.
  • Follow style guidelines.
  • Update the changelog.
  • Address all review comments.
    Reviewers, please refer to the Cyclus Guide for Reviewers.

@dean-krueger dean-krueger self-assigned this Jul 20, 2025
@github-actions

github-actions Bot commented Jul 20, 2025

Copy link
Copy Markdown

Build Status Report - dc03eb6 - 2025-07-22 20:37:39 +0000

Build FROM cyclus_20.04_apt/cyclus:latest
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_20.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_20.04_conda/cyclus:latest
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_20.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_apt/cyclus:latest
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_conda/cyclus:latest
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_apt/cyclus:latest
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_conda/cyclus:latest
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️

@dean-krueger

Copy link
Copy Markdown
Contributor Author

Fairly certain these tests are failing because this needs cyclus/cyclus#1884

@dean-krueger
dean-krueger requested a review from gonuke July 20, 2025 17:00
@dean-krueger dean-krueger added this to the 100% Cost milestone Jul 22, 2025

@gonuke gonuke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some design thoughts for moving forward.

Comment thread CHANGELOG.rst

**Added:**

* Added CalculateBidPrice() functionality from facility_cost.cycpp.h to Enrichment, Source, and Fuel_Fab (#656)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Added CalculateBidPrice() functionality from facility_cost.cycpp.h to Enrichment, Source, and Fuel_Fab (#656)
* Added CalculateUnitPrice() functionality from facility_cost.cycpp.h to Enrichment, Source, and Fuel_Fab (#656)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang, I thought I got them all.

Comment thread src/enrichment.cc
Comment on lines +164 to +165
double prev_weighted_cost = 0.0;
double prev_qty = 0.0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to put an ad-hoc solution into cycamore like this, particularly when we imagine a more cyclus-wide solution. Best to just assume 0 for the cost of material for now until we tackle that more seriously.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me, I'll change it like that and then spend some time trying to implement a material/resource cost.

Comment thread src/source.cc
Material::CreateUntracked(*bit, context()->GetRecipe(outrecipe));
port->AddBid(req, m, this);

double pref = 1.0 /CalculateUnitPrice(throughput, target->quantity());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many components of this price are constants over time for any given facility. I wonder if we can break it down and only calculate those parts once. Maybe all the "process costs" are constants and the "input costs" are not? So we make 2 functions, one that we call once at initialization to calculate the constant part and store it, and then add in the input costs which each bid?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be a way to update the "constant" costs if/as necessary, but not with every bid

@dean-krueger

Copy link
Copy Markdown
Contributor Author

I'm thinking more and more that this should maybe not go in Cycamore, but its own repo for financial modeling, and I think we should maybe discuss that at the NEUP Project Meeting we're having tomorrow.

@gonuke gonuke linked an issue Sep 8, 2025 that may be closed by this pull request
@dean-krueger

Copy link
Copy Markdown
Contributor Author

We may now be going in a different direction entirely. Converting to a Draft for now...

@dean-krueger

Copy link
Copy Markdown
Contributor Author

I think this gets closed now that we've rethought how this all works.

@dean-krueger dean-krueger removed this from the DK Stranded milestone May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants